gpt4 book ai didi

iphone - 奇怪的 objective-c 语法——方括号和@符号

转载 作者:可可西里 更新时间:2023-11-01 05:06:21 29 4
gpt4 key购买 nike

我在我的一个项目中使用 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]]
]
];

最佳答案

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

参见:

关于iphone - 奇怪的 objective-c 语法——方括号和@符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13482523/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com