在创建UIButton时,点击动作里老是读取不到成员变量。调试N次,一到读取那个列表时程序就直接退出。
-(void)selectCompany:(id)sender{
int index = [sender tag];
//NSLog(@"sender:%d",index);
NSArray *company = [companyList objectAtIndex:index];
//NSLog(@"selectCompany:name:%@,id:%@",[company valueForKey:@"name"],[company valueForKey:@"cid"]);
CompanyMatchController *cMatch = [[CompanyMatchController alloc]initWithCidAndName:[company valueForKey:@"cid"] cName:[company valueForKey:@"name"]];
[self.navigationController pushViewController:cMatch animated:YES];
}
就这是
NSArray *company = [companyList objectAtIndex:index];
这里程序就直接退出了。
经别人指数,因为你self.是对你那对象retain了一次,所以就好了
后来慢慢地检查成员变量的初始化。发现问题问题出自:
-(void)fetchData{
[self removeAllView];
companyList = [JSONParser loadData:@"http://3g.wapzq.com/odds/json/company.jsp" isAllValues:NO valueForKey:@"list"];
[[WaitDialog sharedWaitDialog]setLoadingLabel:@"正在构造界面..."];
[self makeView];
}
以下
companyList = [JSONParser loadData:@"http://3g.wapzq.com/odds/json/company.jsp" isAllValues:NO valueForKey:@"list"];
要加上self.
self.companyList = [JSONParser loadData:@"http://3g.wapzq.com/odds/json/company.jsp" isAllValues:NO valueForKey:@"list"];
重新编译,运行,哦野。解决了整一个上午的问题。