see*_*ish 4 floating-point int memory-management properties objective-c
我在理解某些事情时遇到了一些麻烦.我在我的应用程序中获得了许多功能:
@property (nonatomic, retain) AVAudioPlayer *audioPlayer;
@property (readwrite) NSInteger buttonCount;
@property (nonatomic, retain) NSString *soundSelected;
@property (readwrite) float fadeDecrease;
@property (readwrite) float fadeDelay;
Run Code Online (Sandbox Code Playgroud)
这些显然都是在我的.m文件中合成的.但是,虽然audioPlayer和soundSelected在dealloc中正常释放,但是int buttonCount给出了这个警告:"无效的接收器类型'NSInteger'"并且浮动实际上使编译器哭了:"无法转换为指针类型"
这是否与它们不属于对象类型和/或不被保留这一事实有关?他们没有被释放可以吗?
谢谢.
yan*_*yan 14
NSInteger,比如float,不是Objective-C类型,不遵循通常的保留/发布模型.他们只是原始人.为属性分配值就足够了.
@property (readwrite, assign) NSInteger buttonCount;
Run Code Online (Sandbox Code Playgroud)
应该是你所需要的一切.
NSNumber 但是确实遵循通常的保留/释放周期,因此相应地添加属性.