Reputation: 3644
can this code cause any potential trouble?
@property (nonatomic, retain) NSDictionary *instanceDictionary;
for(int i = 0; i < 50; i++){
self.instanceDictionary = [NSDictionary alloc] init];
}
or without self
for(int i = 0; i < 50; i++){
instanceDictionary = [NSDictionary alloc] init];
}
I came across situations where a instance variable gets "overridden" like this and was wondering if it could cause any memory problems.
Upvotes: 0
Views: 46
Reputation: 7876
It won't cause any "memory problem". In your code, at each loop iteration, the instanceDictionary
is replaced with a new one.
ARC
will take care of releasing the previous one automatically.
This code is pretty useless though.
Upvotes: 3