[英]using storyboards
I am trying a tutorial for using story board from ray. 我正在尝试使用ray故事板的教程。 I am using a tab bar controller connecting a tableview embedded with navigation controller, and this table view is named as players and a view controller connecting tab bar controller named as gestures. 我正在使用一个选项卡栏控制器连接一个嵌入了导航控制器的表视图,该表视图被命名为播放器,一个视图控制器将选项卡栏控制器连接为手势。 Displaying players game, name and rating in players tableview by storing those details in an object. 通过将这些详细信息存储在对象中,在玩家表格视图中显示玩家的游戏,姓名和等级。 So i have created a new file player with base object to store them as properties now i have to store those properties in an array of the view controller called player view controller and then i have to make the array and some test Player objects in the App Delegate and then assign it to the PlayersViewController's players property using an instance variable.so In AppDelegate.m, i imported player and player view controller.h headers and add a new instance variable named _players. 所以我用基础对象创建了一个新的文件播放器,将它们存储为属性,现在我必须将这些属性存储在称为播放器视图控制器的视图控制器数组中,然后我必须在App中制作该数组和一些测试播放器对象委托,然后使用实例变量将其分配给PlayersViewController的玩家属性。因此在AppDelegate.m中,我导入了玩家和玩家视图controller.h标头,并添加了一个名为_players的新实例变量。 so my code in app delegate.m is as below the error is subscript requires size of interface 'NSARRAY' which is not constant in non-fragile ABI at the line viewcontrollers[0]. 所以我在应用程序委托.m中的代码如下所示,错误是下标要求接口'NSARRAY'的大小,该大小在行viewcontrollers [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;
Using the subscript syntax (ie someArray[0]
) requires Objective-C features that were introduced in the iOS 6 SDK, but afaik Xcode 4.2 only supports iOS 5, so you'd either have to use the old syntax: 使用下someArray[0]
(即someArray[0]
)需要iOS 6 SDK中引入的Objective-C功能,但是afaik Xcode 4.2仅支持iOS 5,因此您要么必须使用旧语法:
UINavigationController *navigationController = [[tabBarController viewControllers] objectAtIndex:0];
//alternatively:
UINavigationController *navigationController = [[tabBarController viewControllers] firstObject];
...or update to a more recent version of Xcode (you can't even submit to the App Store with Xcode 4.2, as far as I'm aware). ...或更新到最新版本的Xcode(据我所知,您甚至无法使用Xcode 4.2提交到App Store)。
如果您只是想获取数组的第一个对象,为什么不使用firstObject?
UINavigationController *navigationController = [[tabBarController viewControllers] firstObject];
You can use below code 您可以使用以下代码
UINavigationController *navigationController =
[tabBarController.viewControllers objectAtIndex:0];
Refer the below links..regarding error and explanation..! 有关错误和说明,请参阅以下链接。
What is a non-fragile ABI? 什么是非脆弱ABI?
Subscript requires size of interface 'NSArray', which is not constant in non-stable ABI 下标需要接口'NSArray'的大小,在不稳定的ABI中,该大小不是恒定的
Hope it helps you...! 希望它可以帮助您...!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.