ユーザーがUITableViewの要素をクリックしたときに、2番目のビューを作成しようとしているiPhoneアプリを作成しています。コードは次のようになります
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に次のメソッドを追加しました。これが呼び出され、この新しいオブジェクトを作成しているユーザーを見つけることができることを期待しています。しかし、それはこの方法で止まりません。
どんな助けでも大歓迎です。
- (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.
}