我得到一個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