Should I free an NSError object for NSFileManager copyItemAtPath: toPath: error :?

NSFileManager has a copy method.

- (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 let him go?

There are other methods, for example, this requires (NSString **) ,

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

Do they follow the same rules of memory management? Release or not, that is the question.

--- Answer

As Anders said, the answer "no" should be issued.

I am confused because the NSPropertyListSerialization class has a method

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

The document says that I should issue the third argument, if not nil. However, it is deprecated and replaced by

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

(NSError **). , . .

---

Apple , , :

, NSError, .

+3
2

NSError - ,

, ( )

:

+5
[NSPropertyListSerialization propertyListFromData:(NSData *) mutabilityOption:(NSPropertyListMutabilityOptions) format:(NSPropertyListFormat *) errorDescription:(NSString **)]

- ,

(NSString **)

, , . ,

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

, , , .

+1

Source: https://habr.com/ru/post/1761856/


All Articles