第一种
typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize); @interface ssyTest : NSObject { SDWebImageDownloaderProgressBlock ssyblock; } - (void)testssy:(NSString *)str block:(SDWebImageDownloaderProgressBlock)ssy;
#import "ssyTest.h" @implementation ssyTest - (void)testssy:(NSString *)str block:(SDWebImageDownloaderProgressBlock)ssy { ssyblock = ssy; [self performSelector:@selector(jjj) withObject:nil afterDelay:5]; } - (void)jjj { ssyblock(1,2); }
ssyTest *ssy = [[ssyTest alloc] init]; [ssy testssy:@"3" block:^(NSInteger s1,NSInteger s2){ NSLog(@"%d %d",s1,s2); }];
第2中
- (void)testCallback:(void (^)(int ssy,NSString *str))callback;
- (void)testCallback:(void (^)(int ssy,NSString *str))callback { callback(5,@"ssy"); }
[ssy testCallback:^(int index,NSString *str){ NSLog(@"%d %@",index,str); }];
时间: 2024-11-05 18:56:13