iphone - Objective-C 2.0; Assigning a Property; Leaking Memory? -
I'm still learning about objective-cum-memory management. I'm going to implement several simple sections in an example program. I am trying to make what I am making.
As an example, I have a definition of the following category:
#import & lt; UIKit / UIKit.h & gt; @ Interface Custom Wii Controller: UIViewController {customObject * myCustomObject; } @ Property (Maintaining) custom object * myCustomObject; - (zero) Replace CustomObject: (customObject *) newObject; @end For the property, I use the standard synthesis keyword ...
@myCustomObjectControl; Then please assume that in the example of customview controller myCustomObject is already set with a valid value and is in use. Replace method then CustomObject is defined as:
- Replace (zero) CustomObject: (customObject *) newObject {// Does this cause memory leak because I Just on the current property / Self.myCustomObject = newObject; } asks as a comment, Is this leakage memory? Or is it a valid way of changing the previous object with a new object?
Thank you, Frank
This is absolutely valid, and not leak memory synthesized accessories Management is managed to maintain the right way.
(In a different form, you do not need to replace CustomObject: method; Because your property is read-written by default, you have an automatically generated setCustomObject: method using your class , And which adheres to the normal coca naming conventions.)
Comments
Post a Comment