我想传递第一个视图中的视图,就像在这里一样
if (self.bookDetailViewController == nil)
{
iPhoneStreamingPlayerViewController *aBookDetail = [[iPhoneStreamingPlayerViewController alloc] initWithNibName:@"iPhoneStreamingPlayerView" bundle:nil];
self.bookDetailViewController = aBookDetail;
NSLog(@"View initilaized");
[aBookDetail release];
}
//call a method from another class like over here
[booksNavController1 nowPlayingView:bookDetailViewController];
//in 2nd view controller
-(void)nowPlayingView:(iPhoneStreamingPlayerViewController *)NPView
{
nowPlayingSong = NPView;
}
-(void)getSng:(NSString *)sng
{
name = sng;
}
//ibacton for toolbar button
-(IBAction)nowPlaying
{
Music_appAppDelegate *delegate = [[UIApplication sharedApplication]delegate];
[delegate.booksNavController pushViewController:nowPlayingSong animated:YES];
}
这是什么是nsloged“应用程序试图在目标上推送一个nil视图控制器。 终止以响应SpringBoard的终止。“
答案 0 :(得分:0)
不要发布aBookDetail。即注释掉这一行:
[aBookDetail release];
试一试,看看它是否有效。
答案 1 :(得分:0)
您必须对程序进行不同的构建。你得到null的原因是你的类在打印输出之前执行。
Parser *parserClass = [Parser new];
parserClass.array = [[NSArray alloc]initWithObjects:@"One",@"Two", nil];
NSLog(@"%@", parserClass.array);
很抱歉,你必须以不同的方式构建你的课程。
或者你可以使用(AppDelegate *)[[UIApplication sharedApplication]delegate];
来允许在类和AppDelegate之间共享,然后相应地进行子类化。