Re: IBOutlets or property + binding
You got it right :-). That's what I've been doing. I was just wondering whether people would use binding in that case. thanks a lot for clarification. Cheers Chris On 20.11.2009, at 20:02, Karolis Ramanauskas wrote: Let me see. The way I understand what you want to do is this: You have some controls in your window: c1, c2, c3, c4... You don't care to be notified when they change. Only thing you care about is to read their values when you click a button. I thing the best thing to do here is just create a bunch of IBOutleted ivars: IBOutlet NS... * c1 IBOutlet NS... * c2 IBOutlet NS... * c3 IBOutlet NS... * c4 Then in you simply have one method that responds to a click: (IBAction)buttonClicked:(id)sender { NSInteger var1 = [c1 intValue]; NSInteger var2 = [c2 ... do whatever... } So in this method you read the values, do something with them and you're done! Peace, Karolis ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IBOutlets or property + binding
Let me see. The way I understand what you want to do is this: You have some controls in your window: c1, c2, c3, c4... You don't care to be notified when they change. Only thing you care about is to read their values when you click a button. I thing the best thing to do here is just create a bunch of IBOutleted ivars: IBOutlet NS... * c1 IBOutlet NS... * c2 IBOutlet NS... * c3 IBOutlet NS... * c4 Then in you simply have one method that responds to a click: (IBAction)buttonClicked:(id)sender { NSInteger var1 = [c1 intValue]; NSInteger var2 = [c2 ... do whatever... } So in this method you read the values, do something with them and you're done! Peace, Karolis ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IBOutlets or property + binding
On Nov 20, 2009, at 2:13 AM, Christian Ziegler wrote: > > On 19.11.2009, at 18:45, Keary Suska wrote: > >> On Nov 19, 2009, at 10:32 AM, Christian Ziegler wrote: >> >>> For instance I got a NSStepper and I only need the integerValue of that >>> stepper. I could either define an IBOutlet and access the integerValue with >>> [stepper integerValue], or I could define a property and bind the steppers >>> value to it. As I mentioned I don't have to manipulate that stepper in any >>> way, I really only need the value. I just wanna know what's best practice. >> >> Bindings are generally used to synchronize between a model object and view. >> When considering a one-way actions, I generally use IBOutlets to manipulate >> a view, but use target-action for passive activities. So, if it were me, and >> all I cared about was what value an NSStepper was set to, I would just set >> the target/action to my controller object and read the value in the action. >> Although in this case I would set autorepeat to NO so my method is only >> called once. > > In the action method, do you store the changed value in a variable? You could, although base on the additional information you sent before, an IBOutlet may be a better choice. Keep in mind that there is no real "right way" here. Outlet vs action is simply a stylistic decision, although outlets are a bit more extensible and may make later refactoring a little easier. Bindings, on the other hand, carry both a coding, debugging, and performance overhead that may be unnecessary for simpler operations (or in any case where it isn't sensible to have a model object). I would finally add that bindings are not *wrong* for your example--they are simply the more complex choice. If you search the archives you will find developers who shun them religiously, and others who swear by them. I like them personally for many things, but avoid them in situations where they needlessly over-complexify my design. HTH, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IBOutlets or property + binding
On 19.11.2009, at 18:45, Keary Suska wrote: > On Nov 19, 2009, at 10:32 AM, Christian Ziegler wrote: > >> For instance I got a NSStepper and I only need the integerValue of that >> stepper. I could either define an IBOutlet and access the integerValue with >> [stepper integerValue], or I could define a property and bind the steppers >> value to it. As I mentioned I don't have to manipulate that stepper in any >> way, I really only need the value. I just wanna know what's best practice. > > Bindings are generally used to synchronize between a model object and view. > When considering a one-way actions, I generally use IBOutlets to manipulate a > view, but use target-action for passive activities. So, if it were me, and > all I cared about was what value an NSStepper was set to, I would just set > the target/action to my controller object and read the value in the action. > Although in this case I would set autorepeat to NO so my method is only > called once. > > HTH, > > Keary Suska > Esoteritech, Inc. > "Demystifying technology for your home or business" > In the action method, do you store the changed value in a variable? Cheers, Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IBOutlets or property + binding
target/action is inappropriate since no action is needed at the time the value was changed. Instead, once the user clicks a button I compute something hence I read the values from the steppers and stuff. But that doesn't change much does it :) Cheers, Chris On 19.11.2009, at 18:51, Karolis Ramanauskas wrote: > Arghh... I was beaten to an answer! :) Slow typing... > > Yeah, with bindings you will get a two-way connection. If you change your > property's value programmatically, the stepper will update also. > > Instead of target-action you could set up an iboutleted property, connect > stepper to it and observe that property for changes. This may be a more > cumbersome approach in this case though. > > Karolis > > On Thu, Nov 19, 2009 at 11:45 AM, Keary Suska > wrote: > >> On Nov 19, 2009, at 10:32 AM, Christian Ziegler wrote: >> >>> For instance I got a NSStepper and I only need the integerValue of that >> stepper. I could either define an IBOutlet and access the integerValue with >> [stepper integerValue], or I could define a property and bind the steppers >> value to it. As I mentioned I don't have to manipulate that stepper in any >> way, I really only need the value. I just wanna know what's best practice. >> >> Bindings are generally used to synchronize between a model object and view. >> When considering a one-way actions, I generally use IBOutlets to manipulate >> a view, but use target-action for passive activities. So, if it were me, and >> all I cared about was what value an NSStepper was set to, I would just set >> the target/action to my controller object and read the value in the action. >> Although in this case I would set autorepeat to NO so my method is only >> called once. >> >> HTH, >> >> Keary Suska >> Esoteritech, Inc. >> "Demystifying technology for your home or business" >> >> > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/chris.ziegler%40me.com > > This email sent to chris.zieg...@me.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IBOutlets or property + binding
Arghh... I was beaten to an answer! :) Slow typing... Yeah, with bindings you will get a two-way connection. If you change your property's value programmatically, the stepper will update also. Instead of target-action you could set up an iboutleted property, connect stepper to it and observe that property for changes. This may be a more cumbersome approach in this case though. Karolis On Thu, Nov 19, 2009 at 11:45 AM, Keary Suska wrote: > On Nov 19, 2009, at 10:32 AM, Christian Ziegler wrote: > > > For instance I got a NSStepper and I only need the integerValue of that > stepper. I could either define an IBOutlet and access the integerValue with > [stepper integerValue], or I could define a property and bind the steppers > value to it. As I mentioned I don't have to manipulate that stepper in any > way, I really only need the value. I just wanna know what's best practice. > > Bindings are generally used to synchronize between a model object and view. > When considering a one-way actions, I generally use IBOutlets to manipulate > a view, but use target-action for passive activities. So, if it were me, and > all I cared about was what value an NSStepper was set to, I would just set > the target/action to my controller object and read the value in the action. > Although in this case I would set autorepeat to NO so my method is only > called once. > > HTH, > > Keary Suska > Esoteritech, Inc. > "Demystifying technology for your home or business" > > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IBOutlets or property + binding
On Nov 19, 2009, at 10:32 AM, Christian Ziegler wrote: > For instance I got a NSStepper and I only need the integerValue of that > stepper. I could either define an IBOutlet and access the integerValue with > [stepper integerValue], or I could define a property and bind the steppers > value to it. As I mentioned I don't have to manipulate that stepper in any > way, I really only need the value. I just wanna know what's best practice. Bindings are generally used to synchronize between a model object and view. When considering a one-way actions, I generally use IBOutlets to manipulate a view, but use target-action for passive activities. So, if it were me, and all I cared about was what value an NSStepper was set to, I would just set the target/action to my controller object and read the value in the action. Although in this case I would set autorepeat to NO so my method is only called once. HTH, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IBOutlets or property + binding
On 19.11.2009, at 18:27, Karolis Ramanauskas wrote: >> >> Would you create IBOutlets or properties + binding in that case? > > > You will need to give an example of exactly what you want to accomplish. > What values do you need?, etc. Then, perhaps it will be easier to answer. > > Peace > - Hide quoted text - For instance I got a NSStepper and I only need the integerValue of that stepper. I could either define an IBOutlet and access the integerValue with [stepper integerValue], or I could define a property and bind the steppers value to it. As I mentioned I don't have to manipulate that stepper in any way, I really only need the value. I just wanna know what's best practice. Cheers, Chris > > On Thu, Nov 19, 2009 at 5:48 AM, Christian Ziegler > wrote: > >> Hi all, >> >> once again I got a rather general question: >> >> Say we got some view-elements which we don't wanna change in any way. We >> only need to read their value to compute something. Would you create >> IBOutlets or properties + binding in that case? Those values are not part of >> my model. They are not being persisted and I only need them temporarily to >> compute stuff. >> >> Thanks in advance, >> Chris > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/chris.ziegler%40me.com > > This email sent to chris.zieg...@me.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IBOutlets or property + binding
> > Would you create IBOutlets or properties + binding in that case? You will need to give an example of exactly what you want to accomplish. What values do you need?, etc. Then, perhaps it will be easier to answer. Peace - Hide quoted text - On Thu, Nov 19, 2009 at 5:48 AM, Christian Ziegler wrote: > Hi all, > > once again I got a rather general question: > > Say we got some view-elements which we don't wanna change in any way. We > only need to read their value to compute something. Would you create > IBOutlets or properties + binding in that case? Those values are not part of > my model. They are not being persisted and I only need them temporarily to > compute stuff. > > Thanks in advance, > Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com