I have 2 xibs, one for iPad and one for iPhone.
However, currently I have only one view controller for those 2 xibs that works for both iPhone&iPad.
Inside my iPad Xib I have an IBOutlet that doesn’t belong to the iPhone xib.
How should I define that outlet ?
I notice that if I put inside my deallc method, something like this :
-(void) dealloc
{
[outletOnlyForIpad release]
}
The app crashes on the iPhone. Apparently cause it doesn’t instantiates well on the iPhone. (I hoped it would stay nil, but it’s not the case)
I didn’t find any preprocessor macro that I can use so I can declare that Outlet only for iPad.
Is the only way to do it is by checking in runTime something like :
isIpad()
[outletOnlyForIpad SomeMethodOnTheOutlet]
In every place in my controller ?
Your code is correct. That outlet should be staying
nil, so sending it areleasemessage should be harmless. Rather than work around the error, I suggest you check where this outlet is being set and fix the cause of the problem. Are you certain you aren’t connecting anything to it in the iPhone nib?