Re: The best way to call Cocoa methods not implemented in previous versions of the SDK?
Re: The best way to call Cocoa methods not implemented in previous versions of the SDK?
- Subject: Re: The best way to call Cocoa methods not implemented in previous versions of the SDK?
- From: Sean McBride <email@hidden>
- Date: Wed, 07 Sep 2011 13:06:37 -0400
- Organization: Rogue Research Inc.
On Tue, 6 Sep 2011 21:23:45 -0700, Chris Hanson said:
>>> And has been discussed in the rest of the thread, you should not
>leave your Base SDK set to an earlier OS and then invoke methods
>introduced in a later OS, because the new methods may require new-OS
>framework behavior.
>>
>> When did I say anything about invoking methods introduced in a later OS?
>
>This thread is the result of someone trying to take advantage of 10.7
>features in code that needs to run on 10.6.
Not to speak for the OP, but I am in the same situation as him.
It's not a case of "trying to take advantage of 10.7 features", it's a case of 10.7's "Resume" feature breaking *binary* compatibility of apps built with 10.6 deployment & 10.6 SDK.
My app, and others I've used, and probably the OP's, were broken by Resume (basically because it's opt-out, not opt-in).
To "fix" this fast for a dot release (that's built on 10.6-based buildbots) the easiest thing to do is to opt out of Resume, and to do that one must call setRestorationClass:, setRestorable:, etc.
If Apple had provided the ability to opt out using an Info.plist key, as was suggested by many during the seed phase <rdar://9589219>, we would not be having this discussion.
Another point: upping your min SDK requirement means that all your coworkers, build machines, etc. must also update. If you deploy to 10.6, it means you sometimes need to debug on 10.6, and doing that is a PITA if you can't tweak code and rebuild. If you require 10.7 SDK, how do you do that?!
My solution is as others have said, namely:
// If the SDK being compiled against is older than the 10.7 SDK...
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
@interface NSWindow (RRRestorationHackForOldSDKs)
- (void)setRestorationClass:(Class)restorationClass;
- (void)setRestorable:(BOOL)flag ;
- (void)invalidateRestorableState;
@end
#endif
if ([window respondsToSelector:@selector(setRestorationClass:)] &&
[window respondsToSelector:@selector(setRestorable:)] &&
[window respondsToSelector:@selector(invalidateRestorableState)])
{
[window setRestorationClass:Nil];
[window setRestorable:NO];
[window invalidateRestorableState];
}
Cheers,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden