2014-05-13 28 views
0

我來自C++背景,正在學習Objective-C。Objective C expression not understand

我遇到的一種表達方式對我而言並不明確。它如下:

[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; 

我不明白的是"@[indexPath]"。爲什麼我需要[]@

回答

3

的方法是...

- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:... 

和帶有一個數組作爲參數(即多個索引路徑)。

代碼...

@[indexPath] 

使用目標c文字創建一個數組。

在 「老」 的代碼相對應的是...

[NSArray arrayWithObjects:indexPath, nil]; 
+0

非常感謝你。客觀文字在哪裏被描述?我嘗試了谷歌搜索,但我只能在這裏和那裏得到一些不完整的解釋。 – grenzfrequence

+0

http://clang.llvm.org/docs/ObjectiveCLiterals.html在這裏你去:) – Fogmeister

+0

非常感謝。我讀過它,但我不明白爲什麼我需要括號[]。 – grenzfrequence