A collection of example source codes for c/c++ and ios and android platform. It also includes objective c.

Sunday, June 16, 2013

NSFileWrapper setPreferredFilename example in Objective C (iOS).

NSFileWrapper setPreferredFilename

Specifies the receiver’s preferred filename.

- (void)setPreferredFilename:(NSString *)filename

Parameters of [NSFileWrapper setPreferredFilename]
filename
Preferred filename for the receiver.

Discussion of [NSFileWrapper setPreferredFilename]
When a file wrapper is added to a parent directory file wrapper, the parent attempts to use the child’s preferred filename as the key in its dictionary of children. If that key is already in use, then the parent derives a unique filename from the preferred filename and uses that for the key.[NSFileWrapper setPreferredFilename]

When you change the preferred filename of a file wrapper, the default implementation of this method causes existing parent directory file wrappers to remove and re-add the child to accommodate the change. Preferred filenames of children are not preserved when you write a file wrapper to disk and then later instantiate another file wrapper by reading the file from disk. If you need to preserve the user-visible names of attachments, you have to store the names yourself.

Special Considerations
This method raises NSInvalidArgumentException if you pass nil or an empty value for filename.
NSFileWrapper setPreferredFilename example.