IOS 语法 - 关于 NStimer 中 scheduledTimerWithTimeInterval方法传参的问题
IOS 语法 - 关于 NStimer 中 scheduledTimerWithTimeInterval方法传参的问题
使用 NSTimer scheduledTimerWithTimeInterval: target: selector:userInfo: repeats: 的时候有两个地方需要注意 。
首先selector指定的方法必须是带一个参数的方法,并且那个参数的类型是NSTimer *。
其次,参数是靠NSTimer 对象的userInfo属性来传递的。
举个例子:
[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(sendBroadcast:) userInfo:@"hello I‘m the info to send" repeats:NO]; // sendBroadcast的定义形式应该是-(void)sendBroadcast: (NSTimer *)timer { NSString *msg = (NSString *)[timer userInfo]; // [msg isEqualToString @"hello I‘m the info to send"] == YES}
IOS 语法 - 关于 NStimer 中 scheduledTimerWithTimeInterval方法传参的问题
标签:class style 使用 log 问题 方法 it la ca
原文:http://www.cnblogs.com/ziyeSky/p/4156645.html