Objective c 如何将对象从类传递到对象从一个类到另一个类的视图?
我想通过一个像这里一样的第一视图Objective c 如何将对象从类传递到对象从一个类到另一个类的视图?,objective-c,cocoa-touch,uitableview,ios4,uinavigationbar,Objective C,Cocoa Touch,Uitableview,Ios4,Uinavigationbar,我想通过一个像这里一样的第一视图 if (self.bookDetailViewController == nil) { iPhoneStreamingPlayerViewController *aBookDetail = [[iPhoneStreamingPlayerViewController alloc] initWithNibName:@"iPhoneStreamingPlayerView" bundle:nil];
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终止而终止。不要发布详细信息。i、 e.注释掉这一行:
[aBookDetail release];
试试看它是否管用。你必须用不同的结构来组织你的程序。得到null的原因是,类在打印输出之前执行
Parser *parserClass = [Parser new];
parserClass.array = [[NSArray alloc]initWithObjects:@"One",@"Two", nil];
NSLog(@"%@", parserClass.array);
很抱歉,你必须以不同的方式组织课堂
或者您可以使用AppDelegate*[[UIApplication sharedApplication]委托];允许类和AppDelegate之间共享,然后相应地创建子类