I'm having some trouble understanding something. I got a bunch of propeties in my app:
@property (nonatomic, retain) AVAudioPlayer *audioPlayer;
@property (readwrite) NSInteger buttonCount;
@property (nonatomic, retain) NSString *soundSelected;
@property (readwrite) float fadeDecrease;
@property (readwrite) float fadeDelay;
These are obviously all synthesized in my .m file. However, while audioPlayer and soundSelected are released fine in dealloc, the int buttonCount gives this warning: "Invalid receiver type 'NSInteger'" and the floats actually make the compiler cry with: "Cannot convert to a pointer type"
Has this got something to do with the fact that they are not of object types and/or not retained? Is it OK that they are not released?
Thanks.
NSInteger
, like float
, are not Objective-C types and do not follow the usual retain/release model. They're just primitives. Assigning values to the property will be sufficient.
@property (readwrite, assign) NSInteger buttonCount;
should be all you need.
NSNumber
however does follow the usual retain/release cycle, so add attributes accordingly.
Has this got something to do with the fact that they are not of object types and/or not retained? Is it OK that they are not released?
Yes. You can only release objects that have a retain count. Primitive datatypes like int, float, and NSInteger do not need to be retained/released because they are not pointers referring to other parts of memory.
If you want to learn more about memory management, try taking a look at this documentation page:
http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html%23//apple_ref/doc/uid/10000011-SW1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With