Re: Subclassing From Code?
Re: Subclassing From Code?
- Subject: Re: Subclassing From Code?
- From: Patrick Machielse <email@hidden>
- Date: Mon, 17 Nov 2003 13:07:43 +0100
op 17-11-2003 06:50 schreef David McGavern op cocoa-dev-request:
>
How can I dynamically make a class a subclass of another class, from
>
code? For example, if I have an LWSearchField (my own class) that I
>
want to make into a NSSearchField (if 10.3 is detected). Any help is
>
greatly appreciated :-).
David,
If I translate your question to: "I want my program to show a native
NSSearchField when running under 10.3 and an LWSearchField under 10.2 and
earlier" I can think of several solutions:
1) create two different nib's (or window objects inside a nib) and load the
appropriate one for each OS version.
2) after loading your window, check the OS version and dynamically exchange
the ...searchfield if needed.
Option 1 would seem to involve less code, since you'll have to wire up your
searchfields by hand using method 2). There are probably more solutions,
like using a 'widget factory' sporting a method like +(id)nativeSearchField,
but that would probably complicate / change the your program.
Patrick
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.