Re: Developing for Tiger and Panther;
Re: Developing for Tiger and Panther;
- Subject: Re: Developing for Tiger and Panther;
- From: "Matt Budd (Madentec)" <email@hidden>
- Date: Thu, 28 Jul 2005 09:08:24 -0600
Hi Ben,
You're right, this is exactly how I did it at first and everything
worked. The problem happens when instead of using NSAnimation
directly I want to use a subclass of NSAnimation. As per your example:
if( system is less than tiger ) { //can actually test if
(NSClassFromString(@"NSAnimation") == nil)
animationClassToUseAtRuntime = [YourAnimationClass class];
} else {
animationClassToUseAtRuntime = NSClassFromString
(@"MyOtherAnimatoinClassThatIsNSAnimationSubclass");
}
Even though if I am running on Panther, I never execute the else-
condition of that statement, the app still crashes because it have
code for my "MyOtherAnimatoinClassThatIsNSAnimationSubclass" class
that is a subclass of NSAnimation. So when the runtime tries to
+initialize that class, it has to load NSAnimation and can't find it
on Panther. Basically I'm not given a chance to test to see if I am
on Tiger (i.e. if NSAnimation is a valid class) when the Cocoa
runtime +initialize's my subclass.
- Matt
On Jul 28, 2005, at 8:43 AM, Ben Dougall wrote:
On Tuesday, July 26, 2005, at 11:30 pm, Matt Budd (Madentec) wrote:
Hello,
I want to use the new NSAnimation in my code, but my app has to
run in both Tiger and Panther. I've rolled my own Animation class
that works similiar to NSAnimation (i.e. notifying the delgate
when it hits a certain point in the animation), so I was hoping to
be able to use my own class on Panther, and then the NSAnimation
class (with bettter implementations) on Tiger.
What is the best way to do this in code. I would prefer one
executable instead of having to create two different Targets in my
Xcode project. Is there a run-time check to say whether I am
running on 10.3 versus 10.4? I have my project set to "Cross-
Develop using Target SDK: Mac OS X 10.3.9", since that is miminum
requirement.
Thanks for any info...
one thing that might help: classes can be stored in and accessed
from variables. so you can do:
Class animationClassToUseAtRuntime; // a variable of type Class
if( system is less than tiger ) { // however that should be done
animationClassToUseAtRuntime = [YourAnimationClass class];
} else {
animationClassToUseAtRuntime = NSClassFromString(@"NSAnimation");
}
then this for example:
id a = [[animationClassToUseAtRuntime alloc] init];
will create an instance of the appropriate animation class. this
will only work properly i think if your animation class's interface
is the same as NSAnimation's interface -- not sure if they would
have to be fully the same or if you could get away with partially
the same.
so throughout the code from then on for the animation class you
always use the animationClassThatWillBeUsedAtRuntime class variable
and it'll always be the right one. polymorphism is the technical
term for this i think.
you could do the above OS test and class variable assignment at the
start of your app's run and have the class variable as a global
variable so it'll work throughout the app and you only have to
check once.
this is just a suggestion -- there might be a better way.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden