사용자 지정 클래스가 있습니다. 이 클래스의 속성을 주어진 태그별로 반환하는 NSDictionary 유형의이 클래스 속성에 추가하려고합니다. 그러나 나는 그것을 할 수 없다. 그것은 가능하거나 불가능합니까? 나는 오류가 있습니다사용자 지정 클래스 개체로 사전 만들기
[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
CODE :
@interface Car : NSObject
@property (nonatomic, strong) NSNumber *topic;
@property (nonatomic, strong) NSNumber *car;
@property (nonatomic, strong) NSDictionary *variables;
@end
@implementation Car
- (NSDictionary *)variables
{
return @{
@"781" : _topic,
@"782" : _car,
}};
@end
당신 '변수들 '을 읽기 전용 속성으로 만드는 것이 좋을 것입니다. – jlehr
@jlehr 제가 동의하는 동안 [이 대답] (http://stackoverflow.com/a/10758831/2792531y)은 중요하지 않을 수도 있습니다. – nhgrif