所以目前我正在尝试保存 indexPath 并访问它,但我一直收到 EXC_BAD_ACCESS 错误,当我在 xcode 中使用分析工具时,它说在初始化期间存储到我的 indexPath 的值永远不会被读取。有人可以帮忙告诉我这里出了什么问题吗?
设置 indexPath 的方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSURL *requestURL = [[NSURL alloc] initWithString:@"URL"];
//The request
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:requestURL];
request.userInfo = [NSDictionary dictionaryWithObjectsAndKeys:indexPath,@"indexPath", nil];
[request setDelegate:self];
[request startAsynchronous];
[requestURL release];
[request release];
}
访问 indexPath 的方法:
-(void)requestFinished:(ASIHTTPRequest *)request{
UIImage *foodImage = [[UIImage alloc] initWithData:[request responseData]];
NSIndexPath *indexPath = [request.userInfo objectForKey:@"indexPath"];
FoodDescription *detailViewController = [[FoodDescription alloc] initWithNibName:@"FoodDescription" bundle:nil];
// pass the food
detailViewController.aFood = [[NSMutableDictionary alloc] initWithDictionary:[_foodArray objectAtIndex:indexPath.row]];
detailViewController.foodPicture = foodImage;
detailViewController.restaurantName = _restaurantName;
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}