0

example code:

@property (nonatomic) NSDictionary *t

- (instancetype)init {
    self = [super init];
    if (self) {
        self.t = @{@"a": @"b", @"c": @"d"};
    }
    return self;
}

- (void)testMethod {
    //self.t is released! accessing self.t cause an SIGABRT
}

the question is: what's wrong with this code?

It works fine when I use "copy"

self.t = [@{@"a": @"b", @"c": @"d"} copy];

OR

@property (nonatomic, copy) NSDictionary *t
horsley
  • 480
  • 4
  • 10

0 Answers0