开发者

Scheduling an operation (NSTimer?)

开发者 https://www.devze.com 2023-03-14 22:49 出处:网络
I save some images locally. The user can associates/dissociates them to some text. I would to check if an image is associated to a note and, if not, delete it开发者_开发技巧 from the local dir.

I save some images locally. The user can associates/dissociates them to some text. I would to check if an image is associated to a note and, if not, delete it开发者_开发技巧 from the local dir.

Should it better to check this every time the user dissociates the image?

or by scheduling the check?

In the second case, what could I use?


You need to create an NSTimer repeatable instance.

NSTimer* myTimer = [NSTimer scheduledTimerWithTimeInterval: 60.0 target: self
                                       selector: @selector(callAfterSixtySecond:) userInfo: nil repeats: YES];

After each 60.0 second , iOS will call the below function

-(void) callAfterSixtySecond:(NSTimer*) t 
{
    NSLog(@"Check your image here ");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消