可有人請向我解釋,我需要分離出的聲明和塊的定義,就像如下:塊聲明和定義是混亂的iOS
#import <Foundation/Foundation.h>
// Main method
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSLog(@"Hello, World!");
}
}
// Working fine. This code is working fine
- (void) blockSample{
(void) (^myBLock) (id sender);
myBlock = ^(id sender){ // It working fine.
//implementation
}
return 0;
}
/* I need it most work like this.*/
// it shows me error
(void) (^myBLock) (id sender);
myBlock = ^(id sender){ // It shows me error of redefinition.
//implementation
}
你的目標是從一個方法,其中塊具有一個typedef返回塊? – Wain
不僅僅是在課程開始時聲明它並在課程結束時定義。就像c中的函數 –