Re: IB_DESIGNABLE - anyone got it to work?
Re: IB_DESIGNABLE - anyone got it to work?
- Subject: Re: IB_DESIGNABLE - anyone got it to work?
- From: Graham Cox <email@hidden>
- Date: Wed, 13 May 2015 09:04:21 +1000
> On 13 May 2015, at 1:22 am, Sean McBride <email@hidden> wrote:
>
> After some difficulty, yes. But it seems to only support direct subclasses of NSView, not NSControl for example. What's your superclass?
Well, it is a NSControl subclass (in fact the volume knob discussed in another thread - just a handy vehicle to explore this new IB feature). On the occasions where it “crashes” (actually an exception) rather than times out, the stack trace shows that the IB agent is rendering the view’s content on a thread, and after a bit of set-up, calls -drawRect: In this particular case I’m not doing anything that is specific to NSControl - I don’t even use a cell. The exception is thrown when drawing an NSImage. At this point I’m not sure that it being a NSControl subclass would be the issue, because there’s nothing it’s doing different than a custom NSView, but it’s certainly something to try.
One possible issue in this case is that the first time -drawRect: for any instance is called, it calls a class method to load the image from a resource, which is then retained indefinitely. This lazy loading is why the first draw takes 10mS and later ones only 2, but since it’s being invoked on a thread I did need to add some synchronization to the class methods that perform the loading. This seemed to make IB a little happier, in that one instance actually drew as expected in IB, though others still report a time-out and the sometime crash is still happening. (Prewarming the images didn’t make any difference anyway).
I’ve noticed a load of other problems relating to the IBInspectable attribute on properties as well, such as removing the IBInspectable attribute does not remove the value in the nib itself, causng the property to be initialized with a stale and incorrect value. It also doesn’t handle simple enumerated type properties which is a pretty serious limitation. Also changing any of these property values in IB doesn’t reflect the change in the drawn view, though it might be because of the other problems I’m having with that.
At this stage it looks like a useful thing to have in IB, but it’ll be an awful lot nicer when it’s finished.
--Graham
_______________________________________________
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