前もって感謝します。私のアプリケーションでは、tableviewdidselectrowatindexpath メソッドを使用して 2 番目のビュー コントローラーを表示しようとしています。以下は私のコードです。autorelease を使用しない場合は正常に動作しますが、autorelease を使用するとエラーが発生します。NSZombie
Enable を使用してErrorを見つけようとすると、この Autorelease に関するエラーが発生します。同じプロジェクトの他のクラスファイルで使用しているのと同じ方法ですが、その時は正しく機能しています。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
if ([[UIScreen mainScreen] bounds].size.height == 568)
{
CreateMessageViewController *cvc = [[[CreateMessageViewController alloc]initWithNibName:@"CreateMessageViewController"bundle:nil]autorelease];
cvc.Username = [arrayUserName objectAtIndex:indexPath.row];
cvc.UserId = [arrayUserID objectAtIndex:indexPath.row];
cvc.isGroup = @"no";
[self.navigationController pushViewController:cvc animated:YES];
}
else
{
CreateMessageViewController *cvc = [[[CreateMessageViewController alloc]initWithNibName:@"CreateMessageViewControlleriPhone4"bundle:nil]autorelease];
cvc.Username = [arrayUserName objectAtIndex:indexPath.row];
cvc.UserId = [arrayUserID objectAtIndex:indexPath.row];
cvc.isGroup = @"no";
[self.navigationController pushViewController:cvc animated:YES];
}
}
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
CreateMessageViewController *cvc = [[[CreateMessageViewController alloc]initWithNibName:@"CreateMessageViewControlleriPad"bundle:nil]autorelease];
cvc.Username = [arrayUserName objectAtIndex:indexPath.row];
cvc.UserId = [arrayUserID objectAtIndex:indexPath.row];
cvc.isGroup = @"no";
[self.navigationController pushViewController:cvc animated:YES];
}
}
他のクラスファイルで使用したのと同じ方法ですが、エラーやクラッシュは発生しません。そのコードは次のとおりです。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (StudioManger)
{
NSLog(@"You can edit Schedule");
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
if ([[UIScreen mainScreen] bounds].size.height == 568)
{
EditScheduleViewController *esvc = [[[EditScheduleViewController alloc]initWithNibName:@"EditScheduleViewController" bundle:Nil]autorelease];
esvc.StudioID = myStudioID ;
esvc.Fromtime = [arrayfromtime objectAtIndex:indexPath.row];
esvc.Totime = [arraytotime objectAtIndex:indexPath.row];
esvc.Date = [arraydate objectAtIndex:indexPath.row];
esvc.Grouptype = [arraygroupname objectAtIndex:indexPath.row];
esvc.DanceType = [arraydancetype objectAtIndex:indexPath.row];
esvc.Day = [arrayDay objectAtIndex:indexPath.row];
esvc.scheduleid = [arrayScheduleID objectAtIndex:indexPath.row];
esvc.StudioName = StudioName ;
[self.navigationController pushViewController:esvc animated:YES];
}
else
{
EditScheduleViewController *esvc = [[[EditScheduleViewController alloc]initWithNibName:@"EditScheduleViewControlleriPhone4" bundle:Nil]autorelease];
esvc.StudioID = myStudioID ;
esvc.Fromtime = [arrayfromtime objectAtIndex:indexPath.row];
esvc.Totime = [arraytotime objectAtIndex:indexPath.row];
esvc.Date = [arraydate objectAtIndex:indexPath.row];
esvc.Grouptype = [arraygroupname objectAtIndex:indexPath.row];
esvc.DanceType = [arraydancetype objectAtIndex:indexPath.row];
esvc.Day = [arrayDay objectAtIndex:indexPath.row];
esvc.scheduleid = [arrayScheduleID objectAtIndex:indexPath.row];
esvc.StudioName = StudioName ;
[self.navigationController pushViewController:esvc animated:YES];
}
}
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
EditScheduleViewController *esvc = [[[EditScheduleViewController alloc]initWithNibName:@"EditScheduleViewControlleriPad" bundle:Nil]autorelease];
esvc.StudioID = myStudioID ;
esvc.Fromtime = [arrayfromtime objectAtIndex:indexPath.row];
esvc.Totime = [arraytotime objectAtIndex:indexPath.row];
esvc.Date = [arraydate objectAtIndex:indexPath.row];
esvc.Grouptype = [arraygroupname objectAtIndex:indexPath.row];
esvc.DanceType = [arraydancetype objectAtIndex:indexPath.row];
esvc.Day = [arrayDay objectAtIndex:indexPath.row];
esvc.scheduleid = [arrayScheduleID objectAtIndex:indexPath.row];
esvc.StudioName = StudioName ;
[self.navigationController pushViewController:esvc animated:YES];
}
}
else
{
}
}
誰か助けてください、注、私は ARC を使用していません。Xcode 5での作業
NSZombie で得られるエラーは以下のとおりです。
2013-10-28 17:12:34.287 Dance Program[3855:a0b] * -[AppDelegate performSelector:withObject:withObject:]: 割り当て解除されたインスタンス 0xa077590 に送信されたメッセージ