iOS Guides | Samples

MonoTouch.UIKit.UIDocument Class

Abstract base class providing local and cloud-based management of Model data.

See Also: UIDocument

Syntax

[MonoTouch.Foundation.Register("UIDocument", true)]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.iOS, 5, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
[MonoTouch.ObjCRuntime.Unavailable(MonoTouch.ObjCRuntime.PlatformName.TvOS, MonoTouch.ObjCRuntime.PlatformArchitecture.All, null)]
public class UIDocument : NSObject, INSFilePresenter, INSProgressReporting, IDisposable

See Also

Remarks

Application developers can subclass UIDocument to create objects that are "Model-Controllers" and relate to Model (domain) objects analogously to how UIViewController relate to UIViews. iOS provides a number of functions, including background asynchronous reading and writing of application data, automatic and safe data-saving, storage that is automatically coordinated between the application sandbox and cloud services, etc.

At a minimum, application developers need to implement UIDocument.ContentsForType (for storage) and UIDocument.LoadFromContents (for retrieval). Additionally, application developers need to manage the lifecyle of the UIDocument and this requires the application developer to set the preferred storage location, create a file URL, and discover, open, and close the file. Application developers should also track changes and resolve conflicts between document versions.

The members of this class can be used from a background thread.

Related content

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.UIKit.UIDocument are listed below.

See Also: NSObject

Public Constructors

A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
Constructor
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

[read-only]
override
ClassHandleIntPtr. The handle for this class.
[read-only]
DocumentStateUIDocumentState. The current UIDocumentState of this UIDocument. Read-only.
FileModificationDateNSDate. The date and time at which the document file was last modified.
[read-only]
FileTypeString. The Uniform Type Identifier for this UIDocument. Read-only.
[read-only]
FileUrlNSUrl. The file URL from which this UIDocument was initialized. Read-only.
[read-only]
HasUnsavedChangesBoolean. Whether this UIDocument has any unsaved changes.
[read-only]
LocalizedNameString. The localized name of this UIDocument. Read-only.
[read-only]
PesentedItemOperationQueueNSOperationQueue. Gets an operation queue.
[read-only]
PresentedItemURLNSUrl. Gets URL of presented item.
[read-only]
ProgressNSProgress. A NSProgress object that reports on the current operation of this document.
[read-only]
SavingFileTypeString. The file type used for saving this UIDocument.
[read-only]
static
StateChangedNotificationNSString. Notification constant for StateChanged
UndoManagerNSUndoManager. The NSUndoManager for this UIDocument.
UserActivityNSUserActivity. Object that encapsulates user activity information.
[read-only]
static
UserActivityDocumentUrlKeyNSString. Gets the key that specifies the document's URL in the UIDocument.UserActivity property.

Public Methods

AccommodatePresentedItemDeletion(Action<MonoTouch.Foundation.NSError>)
Accomodates the presented subitem deletion.
AccommodatePresentedSubitemDeletion(NSUrl, Action<MonoTouch.Foundation.NSError>)
Accomodates the presented subitem deletion.
AutoSave(UIOperationHandler)
Called by the system immediately prior to automatic saving of UIDocuments with unsaved changes.
AutoSaveAsync() : System.Threading.Tasks.Task<bool>
Called by the system immediately prior to automatic saving of UIDocuments with unsaved changes.
ChangeCountTokenForSaveOperation(UIDocumentSaveOperation) : NSObject
When overridden, returns an object encapsulating document changes. Used with UpdateChangeCount and Save.
Close(UIOperationHandler)
Asynchronously closes the document after saving any changes.
CloseAsync() : System.Threading.Tasks.Task<bool>
Asynchronously closes the document after saving any changes.
ContentsForType(String, out NSError) : NSObject
Application developers should override this method to return the document data to be saved.
DisableEditing()
When overridden, allows app developers to disable editing when it is unsafe to make changes to this UIDocument.
EnableEditing()
When overridden, allows app developers to re-enable editing when it is safe to make changes to this UIDocument.
FinishedHandlingError(NSError, Boolean)
Application developers should call this function when they have finished handling an error.
GetFileAttributesToWrite(NSUrl, UIDocumentSaveOperation, out NSError) : NSDictionary
A dictionary of file attributes to associate with this UIDocument when writing or updating it.
GetFileNameExtension(String, UIDocumentSaveOperation) : String
The file extension to append to the file URL of this UIDocument when writing it.
HandleError(NSError, Boolean)
Called when an error occurs during reading, saving, or reverting this UIDocument.
LoadFromContents(NSObject, String, out NSError) : Boolean
App developers should override this method to load document data into their domain objects.
Open(UIOperationHandler)
Asynchronously opens a document.
OpenAsync() : System.Threading.Tasks.Task<bool>
Asynchronously opens a document.
PerformAsynchronousFileAccess(NSAction)
Schedules a read or write operation on a background thread.
PerformAsynchronousFileAccessAsync() : Task
Schedules a read or write operation on a background thread.
PresentedItemChanged()
Changed NSFileVersion of item.
PresentedItemGainedVersion(NSFileVersion)
Presents gained NSFileVersion of item.
PresentedItemLostVersion(NSFileVersion)
Presents lost version of item.
PresentedItemMoved(NSUrl)
Defines subitem move between URLs.
PresentedItemResolveConflictVersion(NSFileVersion)
Resolves conflict version of item.
PresentedSubitemAppeared(NSUrl)
Sets appearance URL.
PresentedSubitemChanged(NSUrl)
Changed NSFileVersion of subitem.
PresentedSubitemGainedVersion(NSUrl, NSFileVersion)
Presents gained version of subitem.
PresentedSubitemLostVersion(NSUrl, NSFileVersion)
Presents lost version of file.
PresentedSubitemMoved(NSUrl, NSUrl)
Defines subitem move between URLs.
PresentedSubitemResolvedConflictVersion(NSUrl, NSFileVersion)
Resolves conflict version of subitem.
Read(NSUrl, out NSError) : Boolean
Reads the document data from the specified location into the application sandbox.
RelinquishPresentedItemToReader(NSFilePresenterReacquirer)
Relinquishes the presented item to the the reader.
RelinquishPresentedItemToWriter(NSFilePresenterReacquirer)
Relinquishes the presented item to the the writer.
RestoreUserActivityState(NSUserActivity)
Restores the state of the user activity.
RevertToContentsOfUrl(NSUrl, UIOperationHandler)
Reverts the UIDocument to the most recent document data stored on-disk.
RevertToContentsOfUrlAsync(NSUrl) : System.Threading.Tasks.Task<bool>
Reverts the UIDocument to the most recent document data stored on-disk.
Save(NSUrl, UIDocumentSaveOperation, UIOperationHandler)
Saves the document data to the specified location in the application sandbox.
SaveAsync(NSUrl, UIDocumentSaveOperation) : System.Threading.Tasks.Task<bool>
Saves the document data to the specified location in the application sandbox.
SavePresentedItemChanges(Action<MonoTouch.Foundation.NSError>)
Saves changes to the presented item.
UpdateChangeCount(UIDocumentChangeKind)
Updates the change counter by indicating the kind of change.
UpdateChangeCount(NSObject, UIDocumentSaveOperation)
When overridden, can customize the change count with reference to the specified changeCountToken.
UpdateUserActivityState(NSUserActivity)
Updates the activity's state.
UserInteractionNoLongerPermittedForError(NSError)
Indicates that it is no longer safe to proceed without handling the error.
WriteContents(NSObject, NSDictionary, NSUrl, UIDocumentSaveOperation, out NSError) : Boolean
Writes and ensures that the document data is written properly to the specified location in the application sandbox.
WriteContents(NSObject, NSUrl, UIDocumentSaveOperation, NSUrl, out NSError) : Boolean
Writes and ensures that the document data is written properly to the specified location in the application sandbox.