我得到一个NSArray,它被填充到我的UITableViewController的init方法中。对象崩溃应用程序
我在“didSelectRowAtIndexPath”中使用此对象来推送另一个tableviewcontroller。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ablogSingleCatTableViewController *singleCatTableViewController = [[ablogSingleCatTableViewController alloc] initWithStyle:UITableViewStylePlain category:[categories objectAtIndex:indexPath.row]];
[[self navigationController] pushViewController:singleCatTableViewController animated:YES];
[singleCatTableViewController release];
}
这个工作几次,当我开始我的申请。在选择一行并返回到rondom点的主uitableview控制器后,我的应用程序在选择行后崩溃。
我发现一些nslogs,它崩溃,如果我尝试使用我的“类别”对象。
所以
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"before");
NSLog(@"cats: %@", categories);
NSLog(@"after");
ablogSingleCatTableViewController *singleCatTableViewController = [[ablogSingleCatTableViewController alloc] initWithStyle:UITableViewStylePlain category:[categories objectAtIndex:indexPath.row]];
[[self navigationController] pushViewController:singleCatTableViewController animated:YES];
[singleCatTableViewController release];
}
与代码我的应用程序崩溃后的“前” ...“后,”一直没有出现。 我不知道为什么我的“类别”对象崩溃我的应用程序?!
我的类别对象是在我的头文件中定义的,并具有@property(nonatomic,retain)。我合成它并在我的dealloc方法中释放它。
任何人都有想法?
//编辑:
因为意见这里一些更多的细节,:
调试器控制台说:“程序接收到的信号:‘EXC_BAD_ACCESS’
我创建类别数组像这样:
- (void)initCategories {
NSString *path = [[NSBundle mainBundle] pathForResource:@"Categories" ofType:@"plist"];
[self setCategories:[[NSArray alloc] initWithContentsOfFile:path]];
}
调用此方法在我initwithstyle方法
[self initCategories];
我的其他自定义初始化方法看起来是这样的:
- (id)initWithStyle:(UITableViewStyle)style category:(NSDictionary*)cat {
if (self = [super initWithStyle:style]) {
currentCategory = cat;
items = [[NSMutableArray alloc] init];
self.title = [currentCategory objectForKey:@"TITLE"];
//XLog("%@", currentCategory);
}
return self;
}
你能否提供关于碰撞的更多细节?如果你调试应用程序而不是运行它(cmd-Y和cmd-R),你通常会让调试器在崩溃时暂停执行。这样,您可以检查确切的回溯并查看当时任何实例变量的值。 – 2010-02-13 19:59:22
显示你创建分类数组的代码请 – willcodejavaforfood 2010-02-13 19:59:39
我觉得你在ablogSingleCatTableViewController initWithStyle:category:method中有问题。你能发布你的代码吗? – EEE 2010-02-13 20:55:32