0

I tried to find the difference between those two loops in the internet but I didn't find any. I have read some articles they explained in such a way that both are same. I was been asked what's the difference between them and I have said what's there in the arictles. Interviewer said both are not same. So please help me guys what's the difference. Any kind of help is appreciated.

user4150758
  • 384
  • 4
  • 17
  • 1
    From the documentaton. `In Cocoa applications, the run loop for the main thread—the main event loop—is run automatically by the application object.` A event loop is simply a run loop. – MadNik Jul 23 '18 at 16:15

3 Answers3

3

A run loop (NSRunLoop or CFRunLoop) is an event loop. The app's main thread runs a run loop; this is the app's main event loop. Most apps don't have another run loop (at least not one visible to you as a user of the iOS SDK).

If the interviewer thinks there's a difference between an event loop and a run loop on iOS, you'll have to ask them what they mean, because according to Apple's documentation they are the same thing.

https://developer.apple.com/library/ios/documentation/General/Conceptual/Devpedia-CocoaApp/MainEventLoop.html

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
0

For each app it should only have one main event loop that is inside the main thread.

I'm not sure about what's the app's run loop in the interviewer's opinion. But run loop is actually a concept binding with thread. Each NSThread object, including the application’s main thread, has an NSRunLoop object automatically created for it as needed. said in https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSRunLoop_Class/index.html#//apple_ref/doc/uid/TP40003725

xi.lin
  • 3,326
  • 2
  • 31
  • 57
0

I guess the main run loop is a kind of event loop.

there are two figures in https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html (figure 2-1 and figure 2-2)

Figure 2-1 show that the event loop is some loop runs as a part of the controller and figure 2-2 show that the main run loop is the loop used by iOS to manage events.

sorry for my bad English.