[NSError retain]:发送给deallocated实例的消息

时间:2015-03-20 08:07:53

标签: ios objective-c iphone xcode nserror

我正在使用第三方库并调用其中一个函数。

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

第三方apis .h文件看起来像这样。

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

我不确定我是否正确使用此NSError指针,因为我不确定* __ autoreleasing是做什么的。谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

__ autoreleasing意味着库已启用ARC,您不需要释放saveBookmarksWithError方法返回的NSError。如果不想处理错误情况,可以将nil值传递给此方法。否则,您可以传递示例代码中给出的NSError指针,并显示给用户或写入日志。