[fbcocoa] Tutorial_4

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2011 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Sun, 4 Sep 2011 01:55:22 -0400
Steve,

While I've enjoyed your tutorials, personal commitments have 
prevented me from contributing anything meaningful. However, here are 
two suggestions:

[1]. As Bernie earlier noted, at the top of your code consider 
including the FB 5.6.1 directive:

    compile as "Objective-C"

[2]. The default activation policy for unbundled executables that do 
not have Info.plists is NSApplicationActivationPolicyProhibited. 
Please note that your use of:

    [[NSApplication sharedApplication] 
setActivationPolicy:NSApplicationActivationPolicyRegular];

to switch from the default is available only with the 10.6 SDK. I 
would suggest a system compilation warning that your code needs 10.6 
or later to run since your nice tutorials won't compile in Leopard. 
NOTE: You can remark out the line to get the code to run in Leopard, 
but newbies will otherwise face a cryptic failure notice.

In 10.5 you can use something like this as a kludge:

// [NSApplication sharedApplication];
// [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];

NSApplication* app = [NSApplication sharedApplication];

if( [app respondsToSelector: @selector(setActivationPolicy:)] )
{
     NSMethodSignature* method = [[app class] 
instanceMethodSignatureForSelector: @selector(setActivationPolicy:)];
     NSInvocation* invocation = [NSInvocation 
invocationWithMethodSignature: method];
     [invocation setTarget: app];
     [invocation setSelector: @selector(setActivationPolicy:)];
     NSInteger myNSApplicationActivationPolicyAccessory = 0;
     [invocation setArgument: 
&myNSApplicationActivationPolicyAccessory atIndex: 2];
     [invocation invoke];
}

Also a question: Does the code behavior in 10.6 require each tutorial 
to be force quit?

Thanks again for the splendid xib-less effort.

Ken