iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – 奇怪的objective-c语法 – 方括号和@符号大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的一个项目中使用GHSidebarNav,我遇到了这个代码分配一个对象数组.我只是不知道它在做什么.它只是一个阵列吗?什么是这种奇怪的@ […]语法?我之前没见过:

NSArray *controllers = @[
    @[
        [[UINavigationController alloc] initWithRootViewController:[[GHRootViewController alloc] initWithtitle:@"Profile" withRevealBlock:revealBlock]]
    ],@[
        [[UINavigationController alloc] initWithRootViewController:[[GHRootViewController alloc] initWithtitle:@"News Feed" withRevealBlock:revealBlock]],[[UINavigationController alloc] initWithRootViewController:[[GHmessagesViewController alloc] initWithtitle:@"messages" withRevealBlock:revealBlock]],[[UINavigationController alloc] initWithRootViewController:[[GHRootViewController alloc] initWithtitle:@"Nearby" withRevealBlock:revealBlock]],[[UINavigationController alloc] initWithRootViewController:[[GHRootViewController alloc] initWithtitle:@"Events" withRevealBlock:revealBlock]],[[UINavigationController alloc] initWithRootViewController:[[GHRootViewController alloc] initWithtitle:@"Friends" withRevealBlock:revealBlock]]
    ]
];

解决方法

这些是数组文字,一种容器文字,Xcode 4.4及更高版本中的 available.

看到:

> discussion of arrays in the Programming with Objective C的“文字语法”部分
> Objective-C Literals在LLVM站点进行讨论
> WWDC 2012 Modern Objective-C,大约需要19-20分钟
> WWDC 2012 Migrating to Modern Objective-C

大佬总结

以上是大佬教程为你收集整理的iphone – 奇怪的objective-c语法 – 方括号和@符号全部内容,希望文章能够帮你解决iphone – 奇怪的objective-c语法 – 方括号和@符号所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。