tags:

views:

27

answers:

1

Hi,

How to access a variable from an Object in Objective-C. ie if i have a variable of say:

(NSString*) string;

How do i access this through an object?

A: 

Directly by dot notation

obj.myString = str
str = obj.myString

Implement your own getter and setter

[obj setMyString: str]
[obj myString]

Have the compiler implement getter and setter by @property/@synchronized

[obj setMyString: str]
[obj myString]

All methods are covered in the Properties in Objective-C 2.0 Cocoa Cast.

Niels Castle
`[obj setMyString:something];`
KennyTM
Doh, yes! Thanks Kenny!
Niels Castle