Helpful For Iphone
Helpful For Iphone
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Question:
------I found an example of Objective-C/cocoa framework has the following
code.
int main()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]
init];
// Create an array
NSArray *month = [NSArray arrayWithObjects:@ ... nill];
[pool drain];
}
You don't need to release the month instance in the example you
give because the NSArray class method you're calling
(arrayWithObjects:) returns an instance that is autoreleased. By
convention in Cocoa, class methods that start with the name of the
class will return autoreleased instances of that class. These
examples:
[NSString stringWithFormat:@"Holla %@", @"back girl!",
nil];
[NSArray arrayWithObjects:@"Holla", @"back", @"girl!",
nil];
Will both return instances of their respective objects that are
autoreleased.