新手入門。如果我的理解錯誤,讓我糾正一下。iOS中以下語法的含義是什麼? typedef void(^ something)(NSInteger * a);
typedef void (^someString) (datatype variable_name, datatype variable_name).
我基本上是從C背景。
這多少有點像一個typedef爲一個函數指針?..
新手入門。如果我的理解錯誤,讓我糾正一下。iOS中以下語法的含義是什麼? typedef void(^ something)(NSInteger * a);
typedef void (^someString) (datatype variable_name, datatype variable_name).
我基本上是從C背景。
這多少有點像一個typedef爲一個函數指針?..
不完全是一個函數指針,但一個塊。一個塊是C語言的Apple擴展:基本上它實現了lambda函數。它將someString
類型鍵入到不返回任何內容的塊(void
)並取兩個參數。
更多在這裏閱讀: http://en.wikipedia.org/wiki/Blocks_(C_language_extension)
這裏: http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Blocks/Articles/bxUsing.html
其稱爲塊,你可以使用它像一個功能,但它有一些特殊待遇, 退房的Documentation