Reputation: 15
Do I have to call release
in the dealloc
method of a class for non-pointer variables?
e.g.
@interface myClass : NSObject {
BOOL isDirty; // do i have to release this?
NSInteger hoursSinceStart; // and this?
NSDate *myDate; // i will release the pointer in dealloc
}
@property (assign, nonatomic) NSInteger hoursSinceStart; // property to release?
@property (assign, nonatomic) BOOL isDirty; // property to release?
@end
Upvotes: 0
Views: 315
Reputation: 237110
Two things:
You only need to retain and release objects. BOOLs and NSIntegers are not objects, they're primitives.
You generally shouldn't call release
for any assign
property, because you haven't retained it — and of course assign
is the only type that makes sense for primitives like NSIntegers or BOOLs, since you can't retain them in the first place.
Upvotes: 4
Reputation: 2547
You will all release objects that extend NSObjects (or implement NSObject protocol).
please read http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html for better understanding of memory management.
Upvotes: 0
Reputation: 1890
You don't need to release your BOOL or NSInteger. As it turns out, an NSInteger is just a typedef for an int (via is it necessary to release a NSInteger in iphone? )
Upvotes: 0