Re: write dictionary to file
Re: write dictionary to file
- Subject: Re: write dictionary to file
- From: Brock Brandenberg <email@hidden>
- Date: Tue, 08 Apr 2003 23:41:16 -0500
>
I've never used -[NSDictionary dictionaryWithObjectsAndKeys:], but it looks
>
like from the documentation that it's supposed to take a 'NULL' terminated
>
list of key/value pairs, not a 'nil' terminated list. It says: "If any key
>
is nil, an NSInvalidArgumentException is raised."
>
>
Try [NSDictionary dictionaryWithObjectsAndKeys: value, key, NULL ] instead?
Not the correct interpretation, but understandable considering that the
method reference indeed has a typo where it states "null-terminated" list.
First, NULL and nil are the same value with different casts, so it won't
really make a difference:
#define nil (id)0
#define NULL (0)
Second, since dictionaryWithObjectsAndKeys: uses alternating objects and
keys, the first nil object signifies the end of the list. It's the key that
can't be nil if an object is supplied because it would be an object without
a valid key.
As others have already mentioned, it's probably the simple fact that key
must be a string and not a number.
Brock Brandenberg
----- industrial design @ www.bergdesign.com ------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.