为什么我收到此错误“使用未声明的标识符'allArtist'”

时间:2013-11-19 07:36:50

标签: ios

我在songViewController.h中将数组声明为@property(retain,nonatomic) NSmutableArray allArtist 我在另一个类songdetailsViewController中使用了这个数组。但它会出现如下错误:use undeclared identifeir 'allArtist'

我已导入songViewController.h

中的songdetailsViewController.h

1 个答案:

答案 0 :(得分:0)

首先应该使用指针声明属性:

@property(retain,nonatomic) NSMutableArray *allArtist;

要从songdetailsViewController访问它,您必须在其中设置第二个属性:

@property(retain,nonatomic) NSMutableArray *allArtists;

当你按下视图集时:

UIViewController *songdetailsViewController = [[songdetailsViewController alloc]
                                     initWithNibName:@"songdetailsViewController"
                                     bundle:nil];
 songdetailsViewController.allArtists = self.allArtist;

 [[self navigationController] pushViewController:songdetailsViewController animated:YES];

最后,您应该考虑将项目移至ARC。