Re: IBOutlet to different classes, conditional build
Re: IBOutlet to different classes, conditional build
- Subject: Re: IBOutlet to different classes, conditional build
- From: Trygve Inda <email@hidden>
- Date: Thu, 24 Feb 2011 20:16:18 +0000
- Thread-topic: IBOutlet to different classes, conditional build
>>
>> On 24/02/2011, at 5:56 PM, Trygve Inda wrote:
>>
>>> The problem is two-fold:
>>>
>>> 1) How can I have nibs, one with MyObjectClass:NSObject and the other with
>>> MyObjectClass:NSPreferencePane where MyObjectClass is essentially the same
>>> but with a few #ifdef to have conditional compilation.
>>
>> The real problem is that you're trying to define this chimera class in the
>> same header. If you split it into two separate headers, each nib only needs
>> to
>> know about the header that applies to it. Target Membership will do the rest,
>> since the right nib and the right header are part of the same target and
>> there's no crosstalk to the other target.
>
> It seems this is not true.
>
> I have:
>
> MyClass.m (@implementation MyClass) This uses #ifdef to pick the right
> header.
>
> MyClassRetail.h (@interface MyClass : NSPreferencePane)
> MyClassAppStore.h (@interface MyClass : NSObject)
>
> MyNibRetail.xib
> MyNibAppStore.xib
>
> I have two targets - AppStore and Retail.
>
> I import:
>
> MyClass.m, MyClassRetail.h, MyNibRetail.xib to Retail target
> MyClass.m, MyClassAppStore.h, MyNibAppStore.xib to AppStore target.
>
>
> When I open the Retail nib and create an NSObject, then change it's class to
> MyClass... It sees the members from the MyClassAppStore.h file.
>
> It seems .h files are not part of the target really and that it just reads
> the .m files to locate the headers... Even though I imported them seperately
> and indicated which target I wanted.
>
> How can I share the common code?
Update:
It does seem like it works if I create a class that has never been in my
nib, then with the Xcode project CLOSED, open the Retail and AppStore nibs
in IB... Then drag the correct .h file to each IB nib window.
After doing this the object in each ib is independent and has the correct
members (since the .h files contain slightly different IBOutles and such).
However, as soon as I close IB, and open the Xcode project, then open the
nib from within Xcode... When IB opens one of the nibs will have reverted to
the other so that both nibs are using the same header.
I am guessing IB is reading the MyClass.m which has both .h files imported
with #ifdef
There seems to be no way to attach a header file to only one target (unlike
.m or .xib files).
This is going to be a real pain to have several duplicated classes that I
have to update in two places.
_______________________________________________
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