I am building a Mac OS X application and I am trying to register to receive display failure notifications, but now I am really lost. I read Apple documentation and some forum posts, etc., but everyone seems to understand things better than I apparently possess. I understand that I have to request a callback inside the start loop so that it works correctly. However, I do not know how to set up the basic loop of the loop. I also feel that the example that Apple has in its documentation is missing from the materials they expect from me. To show my ignorance, I feel that everything should look.
NSRunLoop *rLoop = [NSRunLoop currentRunLoop]; codeToStartRunLoop void MyDisplayReconfigurationCallBack ( CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo); { if (flags & kCGDisplayAddFlag) { NSLog (@"Display Added"); } else if (kCGDisplayRemoveFlag) { NSLog (@"Display Removed"); } } CGDisplayRegisterReconfigurationCallback(MyDisplayReconfigurationCallBack, NULL);
The actual code I received was from an Apple example, but it tells me that flags is an undeclared identifier at this point and will not compile. Not that it worked correctly, since I don't have it in the startup loop. I was hoping to find a tutorial somewhere that explains registering for a system callback in a run loop, but was not successful. If anyone could point me in the right direction, I would really appreciate it.
(I am sure you can say on my question that I am very green. I taught myself Objective-C from a book as my first programming language. I skipped C, so every once in a while I hit something that I can not understand.)
source share