Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用故事板_Ios_Objective C_Xcode_Nsarray - Fatal编程技术网

Ios 使用故事板

Ios 使用故事板,ios,objective-c,xcode,nsarray,Ios,Objective C,Xcode,Nsarray,我正在尝试使用ray的故事板教程。我正在使用一个选项卡栏控制器连接一个嵌入了导航控制器的表视图,这个表视图被命名为播放器,视图控制器连接一个选项卡栏控制器被命名为手势。通过在对象中存储玩家的详细信息,在玩家表视图中显示玩家的游戏、名称和等级。因此,我创建了一个新的文件播放器,使用基本对象将其存储为属性。现在,我必须将这些属性存储在名为“播放器视图控制器”的视图控制器数组中,然后我必须在应用程序委托中创建数组和一些测试播放器对象,然后使用因此,在AppDelegate.m中,我导入了player和

我正在尝试使用ray的故事板教程。我正在使用一个选项卡栏控制器连接一个嵌入了导航控制器的表视图,这个表视图被命名为播放器,视图控制器连接一个选项卡栏控制器被命名为手势。通过在对象中存储玩家的详细信息,在玩家表视图中显示玩家的游戏、名称和等级。因此,我创建了一个新的文件播放器,使用基本对象将其存储为属性。现在,我必须将这些属性存储在名为“播放器视图控制器”的视图控制器数组中,然后我必须在应用程序委托中创建数组和一些测试播放器对象,然后使用因此,在AppDelegate.m中,我导入了player和player view controller.h标题,并添加了一个名为_players的新实例变量。因此,我在app delegate.m中的代码如下所示。错误是subscript需要接口“NSARRAY”的大小,这在line ViewController[0]的非脆弱ABI中不是常量

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;

如果您只是尝试获取数组的第一个对象,为什么不使用firstObject

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
UINavigationController *navigationController = [[tabBarController viewControllers] firstObject];

如果您只是尝试获取数组的第一个对象,为什么不使用firstObject

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
UINavigationController *navigationController = [[tabBarController viewControllers] firstObject];

如果您只是尝试获取数组的第一个对象,为什么不使用firstObject

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
UINavigationController *navigationController = [[tabBarController viewControllers] firstObject];

如果您只是尝试获取数组的第一个对象,为什么不使用firstObject

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
UINavigationController *navigationController = [[tabBarController viewControllers] firstObject];
您可以使用下面的代码

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
UINavigationController *navigationController = 
    [tabBarController.viewControllers objectAtIndex:0];
请参阅以下链接..关于错误和解释

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
希望它能帮助你

您可以使用以下代码

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
UINavigationController *navigationController = 
    [tabBarController.viewControllers objectAtIndex:0];
请参阅以下链接..关于错误和解释

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
希望它能帮助你

您可以使用以下代码

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
UINavigationController *navigationController = 
    [tabBarController.viewControllers objectAtIndex:0];
请参阅以下链接..关于错误和解释

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
希望它能帮助你

您可以使用以下代码

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
UINavigationController *navigationController = 
    [tabBarController.viewControllers objectAtIndex:0];
请参阅以下链接..关于错误和解释

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;

希望它能帮助你

使用下标语法(即
someArray[0]
)需要iOS 6 SDK中引入的Objective-C功能,但afaik Xcode 4.2仅支持iOS 5,因此您必须使用旧语法:

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
UINavigationController *navigationController = [[tabBarController viewControllers] objectAtIndex:0];
//alternatively:
UINavigationController *navigationController = [[tabBarController viewControllers] firstObject];

…或更新到最新版本的Xcode(据我所知,你甚至无法使用Xcode 4.2提交到App Store)。

使用下标语法(即
someArray[0]
)需要iOS 6 SDK中引入的Objective-C功能,但afaik Xcode 4.2只支持iOS 5,因此,您必须使用旧语法:

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
UINavigationController *navigationController = [[tabBarController viewControllers] objectAtIndex:0];
//alternatively:
UINavigationController *navigationController = [[tabBarController viewControllers] firstObject];

…或更新到最新版本的Xcode(据我所知,你甚至无法使用Xcode 4.2提交到App Store)。

使用下标语法(即
someArray[0]
)需要iOS 6 SDK中引入的Objective-C功能,但afaik Xcode 4.2只支持iOS 5,因此,您必须使用旧语法:

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
UINavigationController *navigationController = [[tabBarController viewControllers] objectAtIndex:0];
//alternatively:
UINavigationController *navigationController = [[tabBarController viewControllers] firstObject];

…或更新到最新版本的Xcode(据我所知,你甚至无法使用Xcode 4.2提交到App Store)。

使用下标语法(即
someArray[0]
)需要iOS 6 SDK中引入的Objective-C功能,但afaik Xcode 4.2只支持iOS 5,因此,您必须使用旧语法:

#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;
UINavigationController *navigationController = [[tabBarController viewControllers] objectAtIndex:0];
//alternatively:
UINavigationController *navigationController = [[tabBarController viewControllers] firstObject];


…或更新到更新版本的Xcode(据我所知,您甚至无法使用Xcode 4.2提交到应用商店)。

风格不错,但当[0]失败时,这会起到什么作用?也许?这取决于OP实际上在做什么。我很难理解OP的要求。@zaph
firstObject
是在iOS 4中引入的,
objectAtIndexedSubscript:
(它基本上是在引擎盖下使用的)在iOS 6中,所以在iOS 5上,第一个可以工作,但后者不行。我没有发现OP使用的是Xcode 4.2,所以你是对的。这实际上是一个正确的解决方案,但缺少@omz给出的理由。Anna在早期编辑中删除了xcode4标记,因此信息丢失。样式很好,但当[0]失败时,这会起到什么作用?可能吧?这取决于OP实际上在做什么。我很难理解OP的要求。@zaph
firstObject
是在iOS 4中引入的,
objectAtIndexedSubscript:
(它基本上是在引擎盖下使用的)在iOS 6中,所以在iOS 5上,第一个可以工作,但后者不行。我没有发现OP使用的是Xcode 4.2,所以你是对的。这实际上是一个正确的解决方案,但缺少@omz给出的理由。Anna在早期编辑中删除了xcode4标记,因此信息丢失。样式很好,但当[0]失败时,这会起到什么作用?可能吧?这取决于OP实际上在做什么。我很难理解OP的要求。@zaph
firstObject
是在iOS 4中引入的,
objectAtIndexedSubscript:
(它基本上是在引擎盖下使用的)在iOS 6中,所以在iOS 5上,第一个可以工作,但后者不行。我没有发现OP使用的是Xcode 4.2,所以你是对的。这实际上是一个正确的解决方案,但缺少@omz给出的理由。Anna在早期编辑中删除了xcode4标记,因此信息丢失。样式很好,但当[0]失败时,这会起到什么作用?可能吧?这取决于OP实际上在做什么。我很难理解OP的要求。@zaph
firstObject
是在iOS 4中引入的,
objectAtIndexedSubscript:
(它基本上是在引擎盖下使用的)在iOS 6中,所以在iOS 5上,第一个可以工作,但后者不行。我没有发现OP使用的是Xcode 4.2,所以你是对的。这实际上是一个正确的解决方案,但缺少@omz给出的理由。Anna在早期编辑中删除了xcode4标记,因此信息丢失。您有四行代码,是哪一行造成了错误?还要花一些时间阅读如何设置问题的格式,特别是如何设置代码的格式,提示“将鼠标移到编辑标题中的{}符号上。哪个版本的Xcode?”
#import "AppDelegate.h"
#import "Player view controller.h"
#import "player.h"

@implementation AppDelegate {
   NSMutableArray *_players; }

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   _players=[NSMutableArray arrayWithCapacity:20];
   player *player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"cricket";
   player1.rating=3;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"name";
   player1.game=@"football";
   player1.rating=3.5;
   [_players addObject:player1];
   player1=[[player alloc]init];
   player1.name=@"tony";
   player1.game=@"handball";
   player1.rating=4;
   [_players addObject:player1];
   UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
   UINavigationController *navigationController = [tabBarController viewControllers][0];
   UINavigationController *navigationController = [tabBarController viewControllers][0]; /*at this point i get a error as  [error: subscript requires size of interface 'NS ARRAY' which is not constant in non-fragile ABI] */
   Player view controller *playersViewController = [navigationController viewControllers][0];  
   playersViewController.players = _players;

   return YES;