Block是一个C语言的特性,它就是C语言的函数指针,在使用中最多的就是进行函数回调或者事件传递,比如发送数据到服务器,等待服务器反馈是成功还是失败,此时block就派上用场了.
基本语法
As a local variable:
returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...};
NSTimer在IOS开发中会经常用到,尤其是小型游戏,然而对于初学者时常会注意不到其中的内存释放问题,将其基本用法总结如下:
NSInvocation *invo = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(f)]];
[invo setTarget:self];
[invo setSelector:@selector(myLog)];
time = [NSTimer timerWithTimeInterval:1 invocation:invo repeats:YES];
[time fire];
[[NSRunLoop mainRunLoop] addTimer:time forMode:NSDefaultRunLoopMode];