I want to use the following: 
class func sleepForTimeInterval(_ ti: NSTimeInterval)
 It is a NSTimer function that I found here. I cant figure out how and where to declare the function. I want a 0.1s delay before executing another function. 
            Asked
            
        
        
            Active
            
        
            Viewed 154 times
        
    0
            
            
         
    
    
        Kazuto Nishimori
        
- 1
- 1
- 
                    Actually, if I were you I'd drop the whole thing. Just stick my `delay` function somewhere and call that: http://stackoverflow.com/a/24318861/341994 – matt Jan 20 '15 at 01:31
1 Answers
0
            
            
        If you want to do something after 0.1, you can probably try this code:
double delayInSeconds = 0.1;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    // do something after delay
});
For beginner, it's the best if you can go check out the documentation. Here is the link about NSTimer: https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/index.html
And I don't think you can do something like what you said by using NSTimer. 
 
    
    
        Lucas Huang
        
- 3,998
- 3
- 20
- 29