Reputation: 1927
I have two classes,In classA I create a variable that I need to use in classB , should i use property ?
is there anyone to explain me easier ,how to set StringValue of variable in one class to the textfield of another class?
thanks
Upvotes: 0
Views: 1103
Reputation: 150745
The simple answer is Yes, use properties, that is what they are for: a simple way of exposing the state of an object to other objects.
The longer answer is that Objective-C 2.0 properties are just a wrapper around the concept of Key-Value-Coding and Key-Value-Observing (KVC/KVO).
It is well worth reading the documentation for these as the concept is fundamental to the way that Cocoa works and understanding them early on in your learning process will save you a lot of trouble in the future.
And, since you will be passing object references around I might as well add a link to the Memory Management Programming Guide which will help you correctly apply the proper memory management attributes to your @property
declarations.
Upvotes: 0