Re: A question involving properties
Re: A question involving properties
- Subject: Re: A question involving properties
- From: Karolis Ramanauskas <email@hidden>
- Date: Sun, 11 Oct 2009 17:26:47 -0500
Cool, I'm quite a beginner myself, so this may be not quite correct...
When you set up your user interface using interface builder and when the
application launches the window it automatically allocates and initializes
all the objects you placed on the window. *I never tried to replace those
objects, nor did I find it necessary.* You simply connect that object in IB
to your IBOutlet so you have a *reference* in your code to access that UI
object. Also I assume, since you did NOT alloc init the original
NSTextField, you can't just ask it to be released. Other objects are still
referencing it. I just assume that the objects I place using IB are readonly
for me. I can change their properties but not the objects themselves... I'm
sure someone will correct me if I'm wrong.
If, however you wanted to do all UI manually, you would have to worry about
initializing UI objects yourself, you wouldn't drag then onto window in IB.
You would have to manually include them in the window, put them at certain
coordinates, etc.
I think your exercise obscured your goal too much. Instance variables are
simply any data that your object may need. Properties simply add accessor
methods to those ivars automatically and make your class KVC/KVO compliant
for those variables. Try playing with simpler ivars, integers, floats,
strings. Try setting and accessing them from other classes, etc. You'll get
a hang of it.
Regards,
Karolis
On Sun, Oct 11, 2009 at 4:50 PM, Michael de Haan <email@hidden> wrote:
>
> On Oct 11, 2009, at 2:35 PM, Karolis Ramanauskas wrote:
>
> OK, perhaps I am misunderstanding you, but if you are simply trying to set
>> the label of the NSTextField you may wanna do this.
>>
>
>
> Well...what I was **really** trying to do was get my head around using
> properties/ivars correctly :-) But, of course, your solution worked
> immediately! So, just for completeness, the reason my approach did not work
> was ?
>
> 1)one cannot simply assign a new object to a control...it's much more
> involved than this
>
> 2) something else?
>
> Thanks again.
>
>
>
>>
> _______________________________________________
>
> 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