2012-11-20 26 views
4

我在我的一個項目中使用GHSidebarNav,並且遇到了分配對象數組的代碼。我只是不知道它在做什麼。它只是一個數組?這是什麼奇怪的@[...]語法?我之前沒有看到:奇怪的objective-c語法 - 方括號和@標誌

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]] 
    ] 
]; 
+1

http://stackoverflow.com/questions/25749/what-does-the-sym bol-represent-in-objective-c –

+0

@RobertHarvey您的鏈接沒有提及新的數組文字語法。 – rmaddy

回答

3

這是一個新的C語言,它聲明瞭一個多維數組。

它替換[NSArray arrayWithObjects:[NSArray arrayWithObjects:...], [NSArray arrayWithObjects:..]]];

+0

謝謝你............... – Imme22009