Reputation: 1990
I would like to know how to release a strong property. I would like to clarify why I intend to do this. I own an object via this property declaration:
@interface MyClass : NSObject {
__strong MyObject *myHeavyObject;
}
@end
I create this object in some method, I use it in another, so on and so forth.
- (void)someMethod {
myHeavyObject = [[MyObject alloc] init];
...
}
- (void)someOtherMethod {
id response = [myHeavyObject getResponse];
}
At some point however, i KNOW i no longer need it, and since it is heavy, I would like to get rid of it:
- (void)someCallDidFinish {
//i no longer need myHeavyObject...how do I get rid of it?
}
I don't want to wait till dealloc since that could be a long time. I know I don't use this object any more, so how can I make it go away? How is this supported in the ARC paradigm? Is this something reasonable to ask for?
Ying
Upvotes: 1
Views: 1145
Reputation: 237010
Just set it to nil. The old value will be released when a new one is set.
Upvotes: 5