Я пытаюсь запустить следующий код:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CellIdentifier";
GradeToolAppDelegate * appDelegate = [UIApplication sharedApplication].delegate;
appDelegate = [UIApplication sharedApplication].delegate;
// Dequeue or create a cell of the appropriate type.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
}
NSLog(@"Array Count: %d", [appDelegate.modules count]);
// Configure the cell.
//cell.textLabel.text = [NSString stringWithFormat:@"Row %d", indexPath.row];
//Module * aModule = [appDelegate.modules objectAtIndex:indexPath.row];
//cell.textLabel.text = aModule.moduleTitle;
return cell;
}
Но приложение просто вылетает с:
2011-05-20 15:38:09.256 GradeTool[3994:207] -[GradeToolAppDelegate modules]: unrecognized selector sent to instance 0x5523f80
2011-05-20 15:38:09.258 GradeTool[3994:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GradeToolAppDelegate modules]: unrecognized selector sent to instance 0x5523f80'
*** Call stack at first throw:
(
0 CoreFoundation 0x00eebbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00ce05c2 objc_exception_throw + 47
2 CoreFoundation 0x00eed6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00e5d366 ___forwarding___ + 966
4 CoreFoundation 0x00e5cf22 _CF_forwarding_prep_0 + 50
5 GradeTool 0x000037ff -[RootViewController tableView:cellForRowAtIndexPath:] + 322
6 UIKit 0x003367fa -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
7 UIKit 0x0032c77f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
8 UIKit 0x00341450 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
9 UIKit 0x00339538 -[UITableView layoutSubviews] + 242
10 QuartzCore 0x01ff8451 -[CALayer layoutSublayers] + 181
11 QuartzCore 0x01ff817c CALayerLayoutIfNeeded + 220
12 QuartzCore 0x01ff137c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
13 QuartzCore 0x01ff10d0 _ZN2CA11Transaction6commitEv + 292
14 UIKit 0x002c519f -[UIApplication _reportAppLaunchFinished] + 39
15 UIKit 0x002c5659 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690
16 UIKit 0x002cfdb2 -[UIApplication handleEvent:withNewEvent:] + 1533
17 UIKit 0x002c8202 -[UIApplication sendEvent:] + 71
18 UIKit 0x002cd732 _UIApplicationHandleEvent + 7576
19 GraphicsServices 0x01a70a36 PurpleEventCallback + 1550
20 CoreFoundation 0x00ecd064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
21 CoreFoundation 0x00e2d6f7 __CFRunLoopDoSource1 + 215
22 CoreFoundation 0x00e2a983 __CFRunLoopRun + 979
23 CoreFoundation 0x00e2a240 CFRunLoopRunSpecific + 208
24 CoreFoundation 0x00e2a161 CFRunLoopRunInMode + 97
25 UIKit 0x002c4fa8 -[UIApplication _run] + 636
26 UIKit 0x002d142e UIApplicationMain + 1160
27 GradeTool 0x00002960 main + 102
28 GradeTool 0x000028f1 start + 53
)
terminate called after throwing an instance of 'NSException'
Кажется, GradeToolAppDelegate * appDelegate = [UIApplication sharedApplication].delegate;
одна из основных проблеми при запуске NSLog(@"Array Count: %d", [appDelegate.modules count]);
вызывает исключение
Может кто-нибудь помочь мне здесь в том, что я делаю неправильно.
Спасибо.