I am puzzled by how is variable declared in objective C.
1: I see @property
and @synthesize
statement being used. My question regarding that is, what are these 2 statement for? Why are they always used together? I guess @synthesize
is a shortcut to create the getter and setter?
2:Say, I want to declare an NSMutableArray that would be only be accessible inside the class that was declared in. I have to perform myArray = [[NSMutableArray alloc] init]
before using the addObject
method to write something to it. When do I release the array then?
3:Is there a different way to declaring a variable that is only accessible only at the class it was declared to being accessible at all classes?
4:Similar to question 2, but now the variable is an NSString. Why I don't have to alloc & init it to share the same variable within its own class? Whats the different between self.myString = @"";
to myString = @"";
Thanks a lot.