This method doesn’t work…but when I move away from returning a dictionary object and return a single array to the table data source, it works perfectly. so the error of my ways is in how i am creating this dictionary…
Any Help?
- (NSDictionary *) returnDictionary {
self.shopNameArray = [[NSArray alloc] arrayWithObjects: @"Item 1", @"Item 2", @"Item 3", nil];
self.shopLocationArray = [[NSArray alloc] arrayWithObjects: @"Cincinnati, OH", @"Phoenix, AZ", @"Tuscon, AZ", nil];
self.shopImageArray = [[NSArray alloc] arrayWithObjects: @"image1", "image2", @"image3", nil];
NSMutableDictionary *theDictionary = [[NSMutableDictionary alloc] retain];
[theDictionary setObject:shopNameArray forKey:@"Shop Name"];
[theDictionary setObject:shopLocationArray forKey:@"Shop Location"];
[theDictionary setObject:shopImageArray forKey:@"Shop Image"];
return theMechanicDictionary;
}
Thanks.
Fixed block of code:
Changes made:
[NSArray arrayWithObjects:…is the format for the particular class method you are trying to call.[NSMutableDictionary dictionary]is the easiest way to get an autoreleased mutable dictionary. Like @Douwe suggested, you may want to init this object with a starting size of 3, but that’s not necessary. It only makes a difference if you’re loading a butt-ton of objects into your dictionary and you don’t want it to continuously be resizing itself.self.shopNameArray =) the name of the iVar will not necessarily be the same.