I have created a sample app where i have created some class inherited from NSObject class for defining different atributes and properties of my object . Now i have a subclass a UIView and also able to show that object in my iphone screen.
Now i have a problem whenever i want to delete a triangle i generally call [self removeFromSuperview];and it remove the view from my screen.
But it is just removing the view from screen not completely deleting the object.
How can i delete the object completely?
From what I gather from your description – how about:
Does that work? Alternatively, you should put this kind of logic in your view controller. Then, is you have a reference to object (say, myObject), then use:
Removing from the super view does not mean delete this object. Your object can very live without being connected to a UIView hierarchy.
EDIT: (to flesh out Peter Deweese’s comment)
When you create an UIView you can do this:
This means that you no long own the view, but the super view does. The super view retains your view when its added as a child, and you relinquish it with release. Later, when you do:
The retain count will drop to 0 and your object will be deleted automatically.
Good idea Peter!