I was wondering if I need to release a copied NSObject? For example, I create only one dictionary that I copy into an array:
Code:
for (int num = 0; num < [object count]; num++) {
[dictionary setObject:[object objectAtIndex:num] forKey:@"x"];
[array addObject:[dictionary copy]];
}
Do I have to release the dictionary? If yes, when?
Thanks
Yes, you do. In this case, you should probably release the copy immediately after adding it to the array, because the array retains anything added to it: