如何向我的位置模型添加公共布爾屬性?例如:location.has_lights = YES;
Objective C布爾屬性和內存
我不明白爲什麼我需要保留NSString,但IDE試圖保留bool時顯示錯誤。
此代碼產生一個 'EXC_BAD_ACCESS'
RKLocation.h
#import <RestKit/RestKit.h>
@interface RKLocation : RKObject {
NSString *_name;
bool has_lights;
}
@property (nonatomic , retain) NSString *name;
@property (nonatomic) bool has_lights;
@end
RKLocation.m
#import "RKLocation.h"
@implementation RKLocation
@synthesize name = _name;
@synthesize has_lights;
- (void)dealloc {
[_name release];
[super dealloc];
}
@end