[Rubycocoa-devel 489] Re: nil assertion for conversion NSArray/NSDictionary

Zurück zum Archiv-Index

Laurent Sansonetti lsans****@apple*****
Mon Dec 11 00:55:35 JST 2006


Hi,

Mmh I see your point. I'm not sure if it's really interesting here as  
it's very usual to have nil values in Ruby arrays, and you probably  
don't expect to get an exception if you pass this array to Cocoa.

Also, NSNull was specifically created for this usage, to put nil  
values in collections, most probably because nil isn't an object in  
ObjC. It's common to get NSNull objects when deserializing a properly  
list for example.

You said that it might be used unexpectedly (so be a bug), do you have  
some test cases?

# I would recommend to translate nil to NSNull, as we already  
translate strings to NSString and etc...

Laurent

On Dec 10, 2006, at 1:36 AM, kimura wataru wrote:

> Hi,
>
> My purpose of this feature is to find bugs caused by unexpected
> nil, not to avoid crashes.
>
> Programmers can use explicitly NSNull.
> I think most of nil/NSNull values in an NSArray do not follow
> Cocoa-programmers' intention.
>
> On Sat, 9 Dec 2006 19:52:27 +0100, Laurent Sansonetti wrote:
>> Hi,
>>
>> Actually, from
>> http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNull_Class/Reference/Reference.html
>>   :
>>
>> "The NSNull class defines a singleton object used to represent null
>> values in collection objects (which don’t allow nil values)."
>>
>> So according to this comment it should be safe to use it in NSArray/
>> NSDictionary.  Also, it just inherits from NSObject, so it's a very
>> basic class that shouldn't cause problems.
>>
>> # I can ask investigate more if you want.
>>
>> Laurent
>>
>> On Dec 9, 2006, at 4:11 PM, kimura wataru wrote:
>>
>>> Hi,
>>>
>>> There are no descriptions about NSNull value in class references
>>> of NSArray and NSMutableArray (except archiving). I suppose using
>>> NSNull into NSArray leads unexpected results.
>>>
>
> -- 
> kimura wataru
> _______________________________________________
> Rubycocoa-devel mailing list
> Rubyc****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel




More information about the Rubycocoa-devel mailing list
Zurück zum Archiv-Index