0

I'm trying to use this method on an NSObject in a macOS Command Line Tool. https://developer.apple.com/documentation/objectivec/nsobject/1416176-performselector?language=objc

This works fine in a normal app but when I try to use it in a Command Line Tool nothings happens. I'm keeping my app running by using dispatch_main(). What else do I need to do to have this method working on an NSObject?

int main(int argc, const char * argv[])
{
    @autoreleasepool
    {
        // ...
    }
    
    dispatch_main();
    return 0;
}
Berry Blue
  • 15,330
  • 18
  • 62
  • 113
  • Try maybe to replace dispatch_main with ```[NSThread sleepForTimeInterval:60];``` and see what happens. But show us the ```// ...``` also – skaak Oct 16 '20 at 17:28
  • 1
    For all asynchronous stuff you need a runloop. – vadian Oct 16 '20 at 17:29
  • @vadian Thank you! Adding `[[NSRunLoop currentRunLoop] run]` is what I needed. – Berry Blue Oct 16 '20 at 18:27
  • @vadian : you should create an official answer. – Mojo66 Oct 18 '20 at 09:53
  • Does this answer your question? [NSURLSessionDataTask completion handler not executing in command line project](https://stackoverflow.com/questions/49162544/nsurlsessiondatatask-completion-handler-not-executing-in-command-line-project) – vadian Oct 18 '20 at 12:53

0 Answers0