I am following the well known Stanford online course in Objective C.
The course builds on a RPN calculator built using Model:View:Controller I have to create a clear button which I have using the following code (which works) into the View controller
self.display.text=@"0";
self.display.history=@"";
self.brain.clear;
in the model (referred to by the object "brain") the only instance variable is a NSMutableArray with the various things entered by the calculator user in it.
I have put a method called "clear" into the model that clears the array using the removeAllObjects method.
I am getting a warning from Xcode that "property access unused getters should not be used for side effects"
I have tried just deleting the brain object using lines like
self.brain dealloc; to no avail.
How should I clear down the brain object correctly?
Try using
[self.brain clear]; // <-- Calls method 'clear' of object brain
instead of
self.brain.clear; // <-- Access property 'clear' of object brain
When you need to call a method you should use the bracket "[" , "]" notation.
[object method];
e.g: [human setAge:12];
When you need to access a property of the object you should use the dot notation.
object.propery;
e.g: age = human.age;