UISplitViewController *splitViewController     = (UISplitViewController *)self.window.rootViewController;
NSArray *arrayViewControllers                  = (NSArray *)splitViewController.viewControllers;

ViewController *masterViewController           = (ViewController *) arrayViewControllers[firstObject];
VideoViewController *detailVideoViewController = (VideoViewController *) arrayViewControllers[lastObject];


错误:*使用未声明的标识符“ firstObject”

错误:*使用未声明的标识符“ lastObject”

什么?

最佳答案

firstObjectlastObject是NSArray的属性。
您不能将其用作下标。

可以将其用作:

ViewController *masterViewController           = (ViewController *) [arrayViewControllers firstObject];
VideoViewController *detailVideoViewController = (VideoViewController *) [arrayViewControllers lastObject];


要么:

ViewController *masterViewController           = (ViewController *) arrayViewControllers.firstObject;
VideoViewController *detailVideoViewController = (VideoViewController *) arrayViewControllers.lastObject;


请参阅NSArray Class Reference以获取更多信息

关于ios - 错误:*在iOS 7项目的NSArray上使用未声明的标识符'firstObject',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27468185/

10-15 15:27