Today, when practicing the code on learning Objective-C on MAC, I entered the following code
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
//omitted
[pool drain];
return 0;
The error reported by the program is “nsautoreleasepool is unavailable: not available in automatic reference counting mode”
After searching, we know that learning Objective-C on MAC uses the old Xcode version, and arc feature is introduced in the version after xcode4.2 to automatically manage memory, so the following code should be sent as follows
@autoreleasepool{
//omitted.
}
PS: some people on the Internet suggest turning off arc in the settings to continue to use nssautoreleasepool. I wonder why this requirement exists. Is it because the old code is compiled with the new Xcode?If it’s a new project, you’d better try to use arc. After all, how wonderful it is to be able to automatically manage memory
Similar Posts:
- Xcode Command PhaseScriptExecution failed with a nonzero exit code
- [Solved] Unity Xcode Error: A build only device cannot be used to run this target
- An error was reported when flash DB init was running, and the init DB command could not be found
- How to Solve Error: [Errno 11001] getaddrinfo failed
- Using react native elements in RN project to report an error: unrecognized font family ‘material icons’
- TypeError: Network request failed
- [Solved] React Project Start Error: Uncaught TypeError: Cannot read property ‘forEach‘ of undefined
- Solutions for scanning for working copies
- The solution of “unsupported major. Minor version 52” in Java project compilation
- [Solved] Error:java: Compilation failed: internal java compiler error