そのため、現在 indexPath を保存してアクセスしようとしていますが、EXC_BAD_ACCESS エラーが引き続き発生し、xcode で Analyze ツールを使用すると、初期化中に 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];
}