First, you should go to this guide for all the rules:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html
... do not accept what people say here as the gospel. There are some exceptions and odd rules that will explain the manual associated with the above.
, : , , alloc -, . , autoreleased (99% . : ., !). Apple - NSNumber .
, , :
- (NSDictionary*) sampleFunction
{
NSMutableDictionary* state = [NSMutableDictionary dictionaryWithCapacity:5];
[state setObject:[NSNumber numberWithInt:self.a] forKey:@"a"];
[state setObject:[NSNumber numberWithInt:self.b] forKey:@"b"];
[state setObject:[NSNumber numberWithInt:self.c] forKey:@"c"];
return state;
}
, autorelease alloc/init:
NSMutableDictionary* state = [[[NSMutableDictionary alloc] initWithCapacity:5]autorelease];
, Apple, , .