我正在编写一个iPhone应用程序,当用户点击UITableView中的一个元素时,该应用程序试图创建第二个视图。代码看起来像如何调试内存分配问题?
ReplyToViewController *reply = [[ReplyToViewController alloc] initWithNibName:@"ReplyTo" bundle:nil];
reply.delegate = self;
Message *message = [resultData objectAtIndex:indexPath.row];
int dbid = [message.bizid intValue];
NSLog(@"dbid=%d",dbid);
reply.currentMessage = message;
reply.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:reply animated:YES];
答复对象得到正确创建和视图是正确的。上面代码段的最后一行调用一些框架代码,最终调用ReplyToViewController的viewDidLoad方法。上面代码中回复对象的地址和viewDidLoad中对象的地址不一样。
任何想法,这个新的对象来自哪里?我该如何调试?我还在ReplyToViewController中添加了init方法,希望它能够被调用,并且我可以找到谁在创建这个新对象。但是这种方法并没有停止。
任何帮助将不胜感激。
- (id) init
{
/* first initialize the base class */
self = [super init];
return self;
}
// Following gets called from the 1st code segment.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(currentMessage.text]; // THIS returns nil and the program fails later in the code.
}