5

プロジェクトの1つで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]]
    ]
];
4

2 に答える 2

7

これらは配列リテラルであり、コンテナリテラルの一種であり、Xcode4.4以降で使用できます。

見る:

于 2012-11-20T21:39:14.000 に答える
3

これは、多次元配列を宣言する新しいObjectiveCリテラルです。

置き換えています[NSArray arrayWithObjects:[NSArray arrayWithObjects:...], [NSArray arrayWithObjects:..]]];

于 2012-11-20T21:34:47.770 に答える