Re: [NSMutableDictionary setObject:forKey:] problem
Re: [NSMutableDictionary setObject:forKey:] problem
- Subject: Re: [NSMutableDictionary setObject:forKey:] problem
- From: Joachim <email@hidden>
- Date: Wed, 19 Oct 2005 19:15:19 -0700
Thanks for your feedback, j o a r, Elias and m. It all makes sense -
even I should have known. The code now works as shown below.
On 19-Oct-05, at 3:15 PM, m wrote:
"@selector(objectForKey)" should be "@selector
(objectForKey:)" (note the colon; this is a common error beginners
make)
Funny enough, I couldn't remember this call, but remembered Will
Shipley had posted a snippet on his blog. And I took the code from
there. Notice the missing colons in his calls - he's obviously a
beginner ;-)
http://wilshipley.com/blog/2005/10/pimp-my-code-interlude-free-code.html
Best regards,
Joachim
- (void) parseXMLData
{
NSDictionary *iPhotoDict = [[NSDictionary alloc]
initWithContentsOfFile:albumDataXMLFilePath];
NSArray *iPhotoAlbums = [iPhotoDict
objectForKey:@"List of Albums"];
NSEnumerator *enumerator = [iPhotoAlbums objectEnumerator];
id iPhotoAlbumDict;
if (albumDict)
[albumDict removeAllObjects];
else
albumDict = [[NSMutableDictionary alloc] init];
while (iPhotoAlbumDict = [enumerator nextObject]) {
if ([iPhotoAlbumDict respondsToSelector:@selector
(objectForKey:)]) {
[albumDict
setObject:[NSDictionary dictionaryWithObjectsAndKeys:
[[iPhotoAlbumDict objectForKey:@"AlbumId"]
copy], @"AlbumId",
[[iPhotoAlbumDict objectForKey:@"Album Type"]
copy], @"AlbumType",
[[iPhotoAlbumDict objectForKey:@"PhotoCount"]
copy], @"PhotoCount",
nil]
forKey:[iPhotoAlbumDict objectForKey:@"AlbumName"]];
}
}
[iPhotoDict release];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden