//.h file
@property(nonatomic, retain) NSMutableDictionary *data;
//.m file
NSMutableDictionary *temp = [[NSMutableDictionary alloc] init];
self.data = temp;
[temp release];
Why is this way (using temporary variable) is better than this
self.data = [[NSMutableDictionary alloc] init];
What is the difference?
The second way leaks the newly-created dictionary. You could use:
And it would be as safe as your first example.
Edited to match OP’s update to the question.