I've been going through the screencasts here to learn how to write a table-based iPhone application, and it's been going pretty smoothly so far. Presently I'm halfway through the third episode, and it's starting to hit a snag.
In order to remove temporary hard-coding for the top layer of the table, the tutorial creates an NSMutableDicitonary
for all the entries and their data, and then creates an NSArray
using the forKeys
statement to get an array with just the headwords to display in the table cells.
The problem I'm having is that the variable for the array refuses to synthesize.
The offending variable is defined in the AppDelegate.h
file with the rest of the properties as follows:
@property (readonly) NSArray *recipes;
It is then synthesized and implemented in the AppDelegate.m
file as follows:
@synthesize recipes;
- (NSArray *)recipes {
return [data allKeys];
}
I inquired with the author of the screencast, and he suggested the following for AppDelegate.h
:
@class Foo :NSObject {
NSArray *_recipes;
}
@property(nonatomic, retain)NSArray *recipes;
@end
And this for AppDelegate.m
:
@implementation Foo
@synthesize recipes = _recipes;
@end
I tried this method, but it created more errors than there were before. What makes this variable definition different from any other @property, and how can I make it behave?