Greetings,
I'm working my way through "Beginning iOS 4 Application Programming" by Wei-Meng Lee. I'm using XCode 4.0.1, but the book was written for an earlier version. So far, I've had no problem adapting the lesson material to any subtle changes.
That said, Chapter 8 focuses on using tableView. The first exercise populated the view from an array. This exercise introduces plists.
exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x8e038f0'
SIGBART occurs on the last line of this code from tableView:cellForRowAtIndexPath:
*year has the value of "Root", which explains why *movieSection yields "Variable is not a CFArray". Okay, so I think I see the problem, but I'm not sure what is causing the problem. self.movieTitles and self.years are populated up in viewDidLoad:
It builds successfully. I've combed it for typos compared to the book, and finding none have concluded that there's some kind of change between XCode versions/frameworks, or I've bunged up the .plist somehow. Obviously, another pair of eyes checking for typos would be helpful.
Below is a copy-n-paste of the plist from XCode to the forum input. If there's a better way of showing a plist, please let me know.
I'm sure this is something simple, and I appreciate your assistance in setting this newbie back on the road of progress. Thanks!
I'm working my way through "Beginning iOS 4 Application Programming" by Wei-Meng Lee. I'm using XCode 4.0.1, but the book was written for an earlier version. So far, I've had no problem adapting the lesson material to any subtle changes.
That said, Chapter 8 focuses on using tableView. The first exercise populated the view from an array. This exercise introduces plists.
exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x8e038f0'
SIGBART occurs on the last line of this code from tableView:cellForRowAtIndexPath:
Code:
NSString *year = [self.years objectAtIndex:[indexPath section]];
NSArray *movieSection = [self.movieTitles objectForKey:year];
cell.textLabel.text = [movieSection objectAtIndex:[indexPath row]];
*year has the value of "Root", which explains why *movieSection yields "Variable is not a CFArray". Okay, so I think I see the problem, but I'm not sure what is causing the problem. self.movieTitles and self.years are populated up in viewDidLoad:
Code:
- (void)viewDidLoad
{
NSString *localPath = [[NSBundle mainBundle] pathForResource:@"Movies" ofType:@"plist"];
NSDictionary *dic = [[NSDictionary alloc] initWithContentsOfFile:localPath];
self.movieTitles = dic;
[dic release];
NSArray *array = [[self.movieTitles allKeys] sortedArrayUsingSelector:@selector(compare:)];
self.years = array;
[super viewDidLoad];
}
It builds successfully. I've combed it for typos compared to the book, and finding none have concluded that there's some kind of change between XCode versions/frameworks, or I've bunged up the .plist somehow. Obviously, another pair of eyes checking for typos would be helpful.
Below is a copy-n-paste of the plist from XCode to the forum input. If there's a better way of showing a plist, please let me know.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>2008</key>
<array>
<string>The Great Debaters</string>
<string>American Gansters</string>
</array>
<key>2006</key>
<array>
<string>A Hand to Guide Me</string>
<string>Inside Man</string>
</array>
<key>2007</key>
<array>
<string>Deja Vu</string>
</array>
<key>2000</key>
<array>
<string>Malcom X</string>
<string>The Pelican Brief</string>
<string>The Hurricane</string>
</array>
<key>2004</key>
<array>
<string>Man on Fire</string>
<string>Out of TIme</string>
<string>Training Day</string>
<string>License to Kill</string>
<string>Carbon Copy</string>
</array>
<key>2002</key>
<array>
<string>John Q.</string>
</array>
<key>2001</key>
<array>
<string>Remember the Titans</string>
<string>The Bone Collector</string>
</array>
</dict>
</plist>
I'm sure this is something simple, and I appreciate your assistance in setting this newbie back on the road of progress. Thanks!
Last edited: