Questions tagged [nsfilewrapper]

On iOS and Mac OS X, the NSFileWrapper class provides access to the attributes and contents of file-system nodes. A file-system node is a file, directory, or symbolic link. Instances of this class are known as file wrappers.

On iOS and Mac OS X, the NSFileWrapper class provides access to the attributes and contents of file-system nodes. A file-system node is a file, directory, or symbolic link. Instances of this class are known as file wrappers.

File wrappers represent a file-system node as an object that can be displayed as an image (and possibly edited in place), saved to the file system, or transmitted to another application.

There are three types of file wrappers:

  • Regular-file file wrapper: Represents a regular file.
  • Directory file wrapper: Represents a directory.
  • Symbolic-link file wrapper: Represents a symbolic link.

A file wrapper has these attributes:

  • Filename. Name of the file-system node the file wrapper represents.
  • file-system attributes. See NSFileManager Class Reference for information on the contents of the attributes dictionary.
  • Regular-file contents. Applicable only to regular-file file wrappers.
  • File wrappers. Applicable only to directory file wrappers.
  • Destination node. Applicable only to symbolic-link file wrappers.
81 questions
2
votes
0 answers

Unblock user interaction in fileWrapperOfType

I would like to implement asynchronous saving in my NSDocument. According to the documentation, I need to return YES in canAsynchronouslyWriteToURL:ofType:forSaveOperation: and then call unblockUserInteraction sometime during writing. In my…
hpique
  • 119,096
  • 131
  • 338
  • 476
1
vote
0 answers

NSDocument file wrapper sync via iCloud doesn't appear to support editing on multiple computers simultaneously

I have a NSDocument-based macOS app that uses file wrappers for the document package. I have added iCloud Drive sync support. If I make changes on one Mac, the document syncs successfully to another. However, if I edit a document on two different…
Dejal
  • 813
  • 6
  • 18
1
vote
1 answer

Handling image load/store in a UIDocument that contains multiple images

I have a simple model object Location with a few text items and a images : [UIImages]?. Location is Codable so I store the text bits as JSON and then write the images into the same FileWrapper. My question is how to store the relationship between…
Maury Markowitz
  • 9,082
  • 11
  • 46
  • 98
1
vote
0 answers

UIDocument + NSFileWrapper + iCloud = Strange Behaviour

I’m trying to write a fairly simple UIDocument based app and I want the data for each document to be a parent directory containing some image files. To get started I chose to use Apple’s ShapeEdit sample as that seems to handle lots of the…
CodeApe
  • 11
  • 2
1
vote
2 answers

Can’t seem to avoid force unwrapping in Swift

Update: this is regarding a Mac app created with the Document-based Application template in Xcode, and I’m overriding override func readFromFileWrapper(fileWrapper: NSFileWrapper, ofType typeName: String, error outError: NSErrorPointer) ->…
magiclantern
  • 768
  • 5
  • 19
1
vote
0 answers

Changes to NSFileWrapper contents visible from terminal but don't show up in Finder

I recently converted my OS X app to use a package-based file format instead of a single-file one. My document class is a sub-class of NSDocument, and I'm using the -fileWrapperOfType: to generate the file wrapper for writing and letting the…
1
vote
0 answers

Why is NSFileWrapper setting the quarantine bit in Sandbox

I can't figure out why my calls to NSFileWrapper's addRegularFileWithContents:preferredFileName: is setting the files quarantine bit (as seen when using xattr -l on the file) when in the sandbox only. My app saves files in the document bundle so…
GenericPtr
  • 677
  • 1
  • 8
  • 18
1
vote
1 answer

Write with NSFileWrapper vs. copy with NSFileManager

Is there a difference between NSURL *referenceURL, *destinationURL ; [[[NSFileManager alloc] init] copyItemAtURL:referenceURL toURL:destinationURL error:NULL] ; and NSURL…
Colas
  • 3,473
  • 4
  • 29
  • 68
1
vote
1 answer

NSFileWrapper and plain, old file handles

We're porting an app with loads of cross-platform code to Cocoa. Using the low-level file handling routines that directly work on files on disk for loading/saving is a mandatory. As the NSFileWrapper is designed to present the contents of files in…
cacau
  • 3,606
  • 3
  • 21
  • 42
1
vote
0 answers

How to update an NSFileWrapper?

I have an NSFileWrapper with some content. I want to save it (writeToURL...:), add new content to it and save it again. I would like to avoid writing again and again the same files. So, if I understood clearly, it means the option…
Colas
  • 3,473
  • 4
  • 29
  • 68
1
vote
2 answers

Why does saving files into a NSDocument create versions of the same file with strange characters in their name?

I’m working on an NSDocument-based application whose document type is a package bundle that contains a bunch of files. I’m saving it thus: - (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError **)outError { if…
Jaanus
  • 17,688
  • 15
  • 65
  • 110
1
vote
1 answer

Moving a package file of UIDocument class to iCloud

I'm writing an app which saves and loads documents both locally and on iCloud. Locally is working fine, but I'm having a problem with iCloud. The documents are saved as a package - the UIDocument reads and writes an NSFileWrapper which contains an…
Nabeel Thobani
  • 939
  • 10
  • 23
1
vote
1 answer

UIDocument loadFromContents should return a NSFileWrapper; returns NSConcreteData instead

I am making a text editor app that stores each of its document as a NSFileWrapper directory, with document text and document title as separate files in the directory. I expect the contents part of loadFromContents: (id) contents to be a…
merah
  • 61
  • 2
  • 10
1
vote
1 answer

Generating thumbnail from video without an AVAsset on Mac OS

I have a document based app here where I need to generate thumbnails from videos I have available in NSFileWrappers. Problem is that I can't get the file URL from the filewrapper, and I can't seem to create a AVURLAsset without a URL. Anybody have…
Christian A. Strømmen
  • 3,181
  • 2
  • 25
  • 46
1
vote
0 answers

distinguish use cases in NSAutosaveElsewhereOperation

I try to add AutoSave support to the Core Data File Wrapper example Now if i have a new/untitled document writeSafelyToURL is called with the NSAutosaveElsewhereOperation type. The bad thing is, I get this type in both typical use cases - new…
Stephan
  • 4,263
  • 2
  • 24
  • 33