Re: nil in cocoa collections
Re: nil in cocoa collections
- Subject: Re: nil in cocoa collections
- From: Ariel Feinerman <email@hidden>
- Date: Wed, 14 Mar 2012 23:23:54 +0300
We use CCSpriteFrameCache from cocos2d then when the frames a removed from
time to time the one or more these "null" values are in the cache
2012/3/14 Jean-Daniel Dupas <email@hidden>
>
> Le 14 mars 2012 à 17:02, Fritz Anderson a écrit :
>
> > On 14 Mar 2012, at 9:49 AM, Ariel Feinerman wrote:
> >
> >> I have an mystique behavior in the NSMutableDictionary
> >>
> >> one cannot while one contains a nil for key and value so when print in
> >> nslog
> >
> >
> >> {
> >> "key" = "value";
> >> (null) = (null);
> >> }
> >
> > (Edited for readability) Am I to understand that this is some kind of
> notation like text property list or JSON?
>
> This is pretty easy to obtain using CFDictionary API, but Cocoa API does
> not allow such state.
>
> CFMutableDictionaryRef dict = CFDictionaryCreateMutable(NULL, 0,
> NULL, NULL);
> CFDictionarySetValue(dict, CFSTR("key"), CFSTR("value"));
> CFDictionarySetValue(dict, NULL, NULL);
> NSLog(@"%@", dict);
>
> And a dictionary created using CF API should not be used using the NS API.
> While they are theoretically tool free bridge, the NS API is not design to
> support custom callback, and so may misbehave in such configuration.
>
> >> one is not an NSNull
> >
> > Which one is the NSNull? And how are you attempting to put the
> nil/NULL/NSNull into the dictionary? Indeed, how are you creating/building
> the dictionary at all?
>
> Both are not NSNull. NSNull description is "<null>", not (null).
>
> >> then
> >>
> >> NSArray *keys = [_f allKeys];
> >>
> >> throwing an exception
> >>
> >> Terminating app due to uncaught exception 'NSInvalidArgumentException',
> >> reason: '*** -[NSArray initWithObjects:count:]: attempt to insert nil
> >> object at objects[31]'
> >
> > The exception means what it says. You can't have nil keys or values in
> Cocoa collections. I'm surprised it got as far as -allKeys, unless you
> aren't telling us something.
>
>
> -- Jean-Daniel
>
>
>
>
>
--
best regards
Ariel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden