Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1023101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:33:49+00:00 2026-05-16T11:33:49+00:00

NSFileManager has a method to do copying. – (BOOL)copyItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error

  • 0

NSFileManager has a method to do copying.

- (BOOL)copyItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error

If an error occurs, the third parameter (NSError **) upon return will contain an NSError object describing the problem.

Question: do I need to release it?

There are some other methods, for example this one takes (NSString **),

NSPropertyListSerialization +(NSData *)dataFromPropertyList:(id)plist format:(NSPropertyListFormat)format errorDescription:(NSString **)errorString

do they follow the same memory management rules? To release or not to, that’s the question.

—Answer

As Anders said, the answer is “not” to release.

I got confused because the class NSPropertyListSerialization has a method

+ (NSData *)dataFromPropertyList:(id)plist format:(NSPropertyListFormat)format errorDescription:(NSString **)errorString

the document says that I should release the third argument if not nil. However it’s deprecated and replaced by

+ (NSData *)dataWithPropertyList:(id)plist format:(NSPropertyListFormat)format options:(NSPropertyListWriteOptions)opt error:(NSError **)error

and the argument is (NSError **) now. No need to release as other similiar methods. So the general memory manegement rule is no need to release this kind of arguments.

—Reference document

In Apple’s Advanced Memory Management Programming Guide, section You Don’t Own Objects Returned by Reference:

When you invoke any of these methods, you do not create the NSError object, so you do not own it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:33:49+00:00Added an answer on May 16, 2026 at 11:33 am

    The returned NSError object is an autoreleased object so you shouldn’t release it

    The argument just tells the function where to put the returned error object (if any)

    EDIT: can’t spell today it seems

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my iPhone projects, I am currently copying files using NSFileManager 's -copyItemAtPath:toPath:error: method.
BOOL success; NSFileManager *fileManager = [[NSFileManager defaultManager]autorelease]; NSError *error; NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory,
NSFileManager* fileManager = [NSFileManager defaultManager]; NSURL* url = [[fileManager URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask] lastObject]; NSLog(@%@,url); NSString*
What's wrong with that? #define AUDIO_NOTES_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@Documents/myApp/Pictures] NSFileManager *NSFm= [NSFileManager defaultManager]; BOOL isDir=YES;
+ (void)findAndCopyOfDatabaseIfNeeded{ NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [path objectAtIndex:0]; NSFileManager
NSDictionary* fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filename error:nil] From the file attribute keys, you can
Does the NSFileManager method contentsEqualAtPath:andPath: create a dynamic checksum to compare two files, does
NSFileManger has this method: - (NSArray *)mountedVolumeURLsIncludingResourceValuesForKeys:(NSArray *)propertyKeys options:(NSVolumeEnumerationOptions)options the docs say it's for
I'm currently using NSFileManager setAttributes to change the permission of a directory. My problem
I'm trying to use NSFileManager to determine if an item is a file or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.