读书时间 2012/01/03 iPhone/iPad

《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];


Note: 35 mins 


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. 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值