mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-14 02:34:17 +02:00
Add @autoreleasepool as alternative to NSAutoreleasePool object.
This commit is contained in:
@@ -28,6 +28,8 @@ int main (int argc, const char * argv[])
|
|||||||
{
|
{
|
||||||
// Create an autorelease pool to manage the memory into the program
|
// Create an autorelease pool to manage the memory into the program
|
||||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
// If using automatic reference counting (ARC), use @autoreleasepool instead:
|
||||||
|
@autoreleasepool {
|
||||||
|
|
||||||
// Use NSLog to print lines to the console
|
// Use NSLog to print lines to the console
|
||||||
NSLog(@"Hello World!"); // Print the string "Hello World!"
|
NSLog(@"Hello World!"); // Print the string "Hello World!"
|
||||||
@@ -268,6 +270,9 @@ int main (int argc, const char * argv[])
|
|||||||
// Clean up the memory you used into your program
|
// Clean up the memory you used into your program
|
||||||
[pool drain];
|
[pool drain];
|
||||||
|
|
||||||
|
// End of @autoreleasepool.
|
||||||
|
}
|
||||||
|
|
||||||
// End the program
|
// End the program
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user