1

I am using a third party library and make a call to one of its functions like this.

NSError* error = nil;
self.updatedDocument.bookmarkParser.bookmarks = newBookmarks;
//save the document
[self.updatedDocument.bookmarkParser saveBookmarksWithError:&error];
[self.updatedDocument saveAnnotationsWithError:&error];

The third party apis .h file looks like this.

/// Saves the bookmark into a plist file at bookmarkPath.
/// @note Saving is done async.
- (BOOL)saveBookmarksWithError:(NSError *__autoreleasing*)error;

I am not sure if I am correctly using this NSError pointer as I am not sure what *__autoreleasing does. Thanks for your help.

Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115
  • `__autoreleasing*` release the objects on returning. I am not sure but i think your assumption about using a released object in second method call is correct. Check the Colin's [answer](http://stackoverflow.com/questions/9502116/use-of-autoreleasing-in-code-snippet-example). [This](http://stackoverflow.com/questions/8862023/in-which-situations-do-we-need-to-write-the-autoreleasing-ownership-qualifier) thread also address this concept. – Gandalf Mar 20 '15 at 13:33

1 Answers1

0

__autoreleasing means the library is ARC enabled and you don't need to release the NSError returned by the saveBookmarksWithError method. You can pass a nil value to this method if don't want to handle the error condition. Otherwise you can pass a NSError pointer as you given in the sample code and display to user or write to log.

Nitheesh George
  • 1,357
  • 10
  • 13