I need to add the Pause / Wait function to the iPhone objective-c app. The sleep () function does not work for me.
You need to add a pause / standby function between them.
myscore += [self getcard]; myscore += [self getcard];
I did not see such a function for objective-c, but I used NSTimer, which calls a specific function in the time interval of your choice.
http://developer.apple.com/iphone/library/documentation/cocoa/reference/foundation/Classes/NSTimer_Class/Reference/NSTimer.html
, scheduleTimerWithTimeInterval: target: selector: userInfo: repeat: . "" , - , , , .
scheduledTimerWithTimeInterval:1 // Ticks once per second target:myObject // Contains the function you want to call selector:@selector(myFunction:) userInfo:nil repeats:YES
[NSRunLoop currentRunLoop] 2 , , :
[NSRunLoop currentRunLoop]
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]];
, , performSelector: withObject: afterDelay: .
: 5 :
[NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:5.0];
dispatch_after GCD ( )
myscore += [self getcard]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ myscore += [self get card]; });
Source: https://habr.com/ru/post/1754898/More articles:Android: Can background activity execute code? - androidUsing gallery to scroll between views - androidКак проверить xml с помощью xml-схемы? - javaКак открыть файл, чье полное имя неизвестно Perl? - fileSilverlight control with code highlighting? - controlsHow to optimize Combres settings (compression, minimization) - asp.net-mvcmsdeploy: Replace provider attribute values during deployment? - deploymentПриложение не соединение с sqlserver вне брандмауэра - sql-serverAnimation CALayer hide - objective-cHow to enable vsync in DirectX10 - windows-7All Articles