Re: initWithFrame not being called on my NSImageView subclass
Re: initWithFrame not being called on my NSImageView subclass
- Subject: Re: initWithFrame not being called on my NSImageView subclass
- From: "Ken Ferry" <email@hidden>
- Date: Thu, 21 Feb 2008 11:48:49 -0800
On Thu, Feb 21, 2008 at 11:30 AM, Shamyl Zakariya <email@hidden> wrote:
> OK, sounds like I'm not out of the woods.
>
> Here's the trouble: I have some controls ( in my toolbar ) controlling
> a couple properties of the image view subclass. Specifically, a zoom
> factor and a tiling mode ( this is just a quick-dirty app for viewing
> compressed DDS textures. I've already written a quicklook plugin and
> an NSCustomBitmapImageRep so the plumbing's all there ).
>
> When I assign a default tiling mode and zoom factor in awakeFromNib,
> for some reason it doesn't "propagate" to the bindings.
>
> NSLogging the order of events, I see something like this:
>
> 1) new document is opened from a DDS file:
> 2) TilingImageView is asked for a scaling factor. _scale is zero so it
> returns zero
> 3) awakeFromNib is called. I call setScale: 1
Are you calling setScale: on the model object, or on the view?
Calling a setter on a bound view object does not propagate the change
to the model.
It's basically exactly like pre-bindings models like delegates or
target-action. The model and the view are not completely aliased to
each other, but each updates the other under certain circumstances.
Typically the view updates the model in response to user actions like
a mouse click, not programmatic actions like calling a setter.
-Ken
> 4) Nothing. My slider's still showing zero.
>
> Now, my slider does work: Dragging it changes the scaling factor. But
> for some reason calling [self setScale: 1] in awakeFromNib doesn't
> notify the slider in my toolbar.
>
> This is why I'm trying to find a way to make certain _scale = 1 before
> bindings queries my image view instance.
>
> email@hidden
> "In the same trial, only 16 percent of those who received placebo
> sandwiches reported experiencing high levels of deliciousness."
> --The Onion
>
>
>
>
> On Feb 21, 2008, at 2:15 PM, Kyle Sluder wrote:
>
> > On Thu, Feb 21, 2008 at 2:06 PM, Mike Abdullah
> > <email@hidden> wrote:
> >> If the view's being loaded from a nib it's archived, so you need -
> >> initWithCoder:
> >
> > I'm not sure -initWithCoder: is guaranteed to be called, and is
> > certainly not the "proper" place to be performing object
> > initialization after awaking from a nib. The official recommendation
> > is to either create an IB plugin so that your version of
> > -initWithFrame: is called at design time, or perform subclass-specific
> > initialization in -awakeFromNib.
> >
> > http://lists.apple.com/archives/cocoa-dev/2002/Jul/msg01647.html
> >
> > --Kyle Sluder
>
> _______________________________________________
>
> 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
>
_______________________________________________
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