《iPhone 3基础教程》
chap 9 http://
Q:为什么没有任何东西睛显示?
A:新版本的程序使用了不同的application life cycle methods
- (void) applicationDidFinishLaunching:(UIApplication *)application {
[windowaddSubview:navController.view];
[windowmakeKeyAndVisible];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[self.windowaddSubview:navController.view];
[self.windowmakeKeyAndVisible];
returnYES;
}
注1:使用didFinishLaunchingWithOptions method.
注2:显示中see的东东,只与windows/view有关,与controller无关。
CheckListController
Q:空的列表?
A:data source method name is wrong !
- (NSInteger)tableView:(UITableView *)tableView numberOfRosInSection:(NSInteger)section {
^ numberOfRowsInSection
return [listcount];
}
Q:有没有一个简单办法直接从protocol中copy方法名?
MoveMe Controller
Q:启动时crsh
A:MoveMeController初始化的时候,类名写错(编译系统居然只是提示,而未错误)
// Move Me
MoveMeController *moveMeController = [[moveMeControlleralloc]initWithStyle:UITableViewStylePlain];
^MoveMeController
moveMeController.title =@"Move Me";
moveMeController.rowImage = [UIImageimageNamed:@"moveMeIcon.png"];
[arrayaddObject:moveMeController];
[moveMeControllerrelease];
DeleteMe Controller
Q: why not delete ?
A: method name for delete commit is wrong
- (void) tableView:(UITableView *)tableView comitEditingStyle:(UITableViewCellEditingStyle)
^ should be commitEditingStyle
editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
...
}
Q: delete发生的时候,地后面的list有没有关质影响?I think no !
Note: 30 mins
Detail Edit Controller ( President View Controller )
Error :
2012-01-03 17:31:43.116 Nav[3159:207] -[__NSCFSet objectAtIndex:]: unrecognized selector sent to instance 0x6001b50
2012-01-03 17:31:43.118 Nav[3159:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet objectAtIndex:]: unrecognized selector sent to instance 0x6001b50'
*** Call stack at first throw:
(
execting the following statement:
President *thePresident = [listobjectAtIndex:row];
改成 [self.list xxxxxx]
(gdb) continue
(gdb) continue
2012-01-03 17:37:23.962 Nav[3196:207] -[UIGestureRecognizerTarget name]: unrecognized selector sent to instance 0x4b2aaf0
2012-01-03 17:37:23.964 Nav[3196:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIGestureRecognizerTarget name]: unrecognized selector sent to instance 0x4b2aaf0'
*** Call stack at first throw:
(gdb) continue
Current language: auto; currently objective-c
(gdb) continue
Program received signal: “EXC_BAD_ACCESS”.
(gdb)
发现:thePresident的name/party两个property是out of scope,而fromYear/toYear则不是。Wiered !
加上强制类型转换
NSUInteger row = [indexPathrow];
President *thePresident = (President *)[self.listobjectAtIndex:row];
cell.textLabel.text = thePresident.name;
cell.detailTextLabel.text = [NSStringstringWithFormat:@"%@-%@", thePresident.fromYear, thePresident.toYear];
step over the following statemnt
cell.textLabel.text = thePresident.name;
the system hanged.
Continue: starting at 8:05 PM
reboot the system. the following errors:
(gdb) continue
Current language: auto; currently objective-c
(gdb) continue
Program received signal: “EXC_BAD_ACCESS”.
(gdb)
change the President.name to President.fullName,
The same error.
* 关于EXC_BAD_ACCESS的一些信息:
http://www.cocoachina.com/macdev/objc/2011/0219/2661.html
President.name is out of scope.
* 8:37 PM,终于找到root cause !
NSMutableArray *array = [unarchiverdecodeObjectForKey:@"Presidents"];
self.list = array;
[unarchiverfinishDecoding];
[unarchiverrelease];
//[array release];
^ 错误release了array!
* 8:50 PM, start PresidentDetailController
9:04 PM, end it. Page 229. To be continued tomorrow.