头文件中可以先定义一个:
-(void) myMethod;
初始化代码:
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(myMethod) userInfo:nil repeats:YES];
-(void)myMethod:(NSTimer*)timer
{
// Now I can access all the properties and methods of myObject
[[timer userInfo] myObjectMethod];
}
释放的代码:
[myTimer invalidate]; myTimer = nil;