PDA

View Full Version : How to prevent idle sleep




BigZ9
Aug 8, 2012, 03:33 PM
I basically have a stop watch application, and I don't want the computer to fall asleep before the timer finishes. I've googled as much as I could and found that one can use listing 2 from http://developer.apple.com/library/mac/#qa/qa1340/_index.html

But I keep getting an error with the line: CFStringRef* reasonForActivity= CFSTR("Describe Activity Type");

can anyone help me out?



chown33
Aug 8, 2012, 04:14 PM
When getting an error, always post the complete text of the error message.

If I had to guess, I'd guess the code has an extra unneeded * in it. AFAIK, the type equivalence is:
CFString : NSString
CFStringRef : NSString *
which means the declared type CFStringRef* is bogus.

Change it to plain unadorned CFStringRef and see if it fixes the error (you should still post the error message, though).

If it does fix it, then go to the QA page, scroll to the bottom, and file a "It's good but..." complaint about the error in the code.

BigZ9
Aug 8, 2012, 06:22 PM
When getting an error, always post the complete text of the error message.

If I had to guess, I'd guess the code has an extra unneeded * in it. AFAIK, the type equivalence is:
CFString : NSString
CFStringRef : NSString *
which means the declared type CFStringRef* is bogus.

Change it to plain unadorned CFStringRef and see if it fixes the error (you should still post the error message, though).

If it does fix it, then go to the QA page, scroll to the bottom, and file a "It's good but..." complaint about the error in the code.

Sorry about that. Your fix worked though! However, now I'm getting 3 critical errors:

Apple Mach-O Linker(Id) Error

"_IOPMAssertionCreateWithName", referenced from:
-[AppController startTimer] in AppController.o

"_IOPMAssertionRelease", referenced from:
-[AppController startTimer] in AppController.o

Symbol(s) not found for architecture x86_64
Linker command failed with exit code 1 (use -v to see invocation)

chown33
Aug 8, 2012, 06:31 PM
What's your current OS version? Xcode version?

What target OS version are you compiling for?

Are you linking against IOKit? I.e. is IOKit one of the frameworks in your Xcode project? The functions in the QA code reside in IOKit, so if you're linking to IOKit, the linker can't possibly find the functions.

BigZ9
Aug 8, 2012, 06:55 PM
I'm an idiot. I forgot to include the IOKit framework… Thanks :p