Become a MacRumors Supporter for $25/year with no ads, private forums, and more!

Mac How to prevent idle sleep

BigZ9

macrumors member
Original poster
Apr 2, 2012
63
0
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

Moderator
Staff member
Aug 9, 2009
8,978
5,512
the top
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.
 
Comment

BigZ9

macrumors member
Original poster
Apr 2, 2012
63
0
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)
 
Comment

chown33

Moderator
Staff member
Aug 9, 2009
8,978
5,512
the top
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.
 
Comment

BigZ9

macrumors member
Original poster
Apr 2, 2012
63
0
I'm an idiot. I forgot to include the IOKit framework… Thanks :p
 
Comment
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.