What is the non-autorelease equivalent of this code?
NSString *nsFName = [[NSBundle mainBundle] pathForResource:nsName
ofType:nsExt inDirectory:nsPath];
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There isn’t one. When you’re using Cocoa, you must have a pool in place:
Part of the GUI application set-up process is establishing one on the main thread; non-GUI programs need to create one as well.
If you’re creating your own threads, you need to create and manage an autorelease pool for each of those threads as well:
Depending on what else you are doing, you may be able to use CoreFoundation. There’s a CFType,
CFBundle, on whichNSBundleis built. It has a functionCFBundleCopyResourceURL()that may do what you need. If you can translate all your code to Core Foundation, then you can escape using a pool, although — as Ken says — it’s really not the burden that you think it is. You’re probably hitting the disk every time you usepathForResource:ofType:anyways.