NSFileWrapper readFromURL options error
- (BOOL)readFromURL:(NSURL *)url options:(NSFileWrapperReadingOptions)options error:(NSError **)outError
Parameters of [NSFileWrapper readFromURL options error]
url
URL of the file-system node corresponding to the file wrapper.
options
Option flags for reading the node located at url. See “File Wrapper Reading Options” for possible values.
outError
If an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you do not want error information.
Return Value of [NSFileWrapper readFromURL options error]
YES if successful. If not successful, returns NO after setting outError to an NSError object that describes the reason why the file wrapper could not be reread.
Discussion of [NSFileWrapper readFromURL options error]
When reading a directory, children are added and removed as necessary to match the file system.
NSFileWrapper readFromURL options error example.
If you're using NSDocument you can get the path of regular-file file wrappers with a little hack.
First create a NSFileWrapper subclass and overload the regular-file methods that receive a URL to store a copy of it.
@implementation RMFileWrapper
- (id) initWithURL:(NSURL *)url options:(NSFileWrapperReadingOptions)options error:(NSError *__autoreleasing *)outError {
if (self = [super initWithURL:url options:options error:outError]) {
self.originalURL = url;
}
return self;
}
- (BOOL) readFromURL:(NSURL *)url options:(NSFileWrapperReadingOptions)options error:(NSError *__autoreleasing *)outError {
BOOL successful = [super readFromURL:url options:options error:outError];
if (successful) {
self.originalURL = url;
}
return successful;
}
@end
First create a NSFileWrapper subclass and overload the regular-file methods that receive a URL to store a copy of it.
@implementation RMFileWrapper
- (id) initWithURL:(NSURL *)url options:(NSFileWrapperReadingOptions)options error:(NSError *__autoreleasing *)outError {
if (self = [super initWithURL:url options:options error:outError]) {
self.originalURL = url;
}
return self;
}
- (BOOL) readFromURL:(NSURL *)url options:(NSFileWrapperReadingOptions)options error:(NSError *__autoreleasing *)outError {
BOOL successful = [super readFromURL:url options:options error:outError];
if (successful) {
self.originalURL = url;
}
return successful;
}
@end