NSDocument

Struct NSDocument 

Source
pub struct NSDocument { /* private fields */ }
Available on crate feature NSDocument only.
Expand description

Implementations§

Source§

impl NSDocument

Source

pub fn init(this: Allocated<Self>) -> Retained<Self>

Source

pub fn initWithType_error( this: Allocated<Self>, type_name: &NSString, ) -> Result<Retained<Self>, Retained<NSError>>

Source

pub fn canConcurrentlyReadDocumentsOfType( type_name: &NSString, mtm: MainThreadMarker, ) -> bool

Source

pub fn initWithContentsOfURL_ofType_error( this: Allocated<Self>, url: &NSURL, type_name: &NSString, ) -> Result<Retained<Self>, Retained<NSError>>

Source

pub fn initForURL_withContentsOfURL_ofType_error( this: Allocated<Self>, url_or_nil: Option<&NSURL>, contents_url: &NSURL, type_name: &NSString, ) -> Result<Retained<Self>, Retained<NSError>>

Source

pub fn fileType(&self) -> Option<Retained<NSString>>

Source

pub fn setFileType(&self, file_type: Option<&NSString>)

Setter for fileType.

This is copied when set.

Source

pub fn fileURL(&self) -> Option<Retained<NSURL>>

Source

pub fn setFileURL(&self, file_url: Option<&NSURL>)

Setter for fileURL.

This is copied when set.

Source

pub fn fileModificationDate(&self) -> Option<Retained<NSDate>>

Source

pub fn setFileModificationDate(&self, file_modification_date: Option<&NSDate>)

Setter for fileModificationDate.

This is copied when set.

Source

pub fn isDraft(&self) -> bool

Source

pub fn setDraft(&self, draft: bool)

Setter for isDraft.

Source

pub fn performActivityWithSynchronousWaiting_usingBlock( &self, wait_synchronously: bool, block: &DynBlock<dyn Fn(NonNull<DynBlock<dyn Fn()>>)>, )

Available on crate feature block2 only.
Source

pub fn continueActivityUsingBlock(&self, block: &DynBlock<dyn Fn() + '_>)

Available on crate feature block2 only.
Source

pub fn continueAsynchronousWorkOnMainThreadUsingBlock( &self, block: &DynBlock<dyn Fn()>, )

Available on crate feature block2 only.
Source

pub fn performSynchronousFileAccessUsingBlock( &self, block: &DynBlock<dyn Fn() + '_>, )

Available on crate feature block2 only.
Source

pub fn performAsynchronousFileAccessUsingBlock( &self, block: &DynBlock<dyn Fn(NonNull<DynBlock<dyn Fn()>>)>, )

Available on crate feature block2 only.
Source

pub unsafe fn revertDocumentToSaved(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub fn revertToContentsOfURL_ofType_error( &self, url: &NSURL, type_name: &NSString, ) -> Result<(), Retained<NSError>>

Source

pub fn readFromURL_ofType_error( &self, url: &NSURL, type_name: &NSString, ) -> Result<(), Retained<NSError>>

Source

pub fn readFromFileWrapper_ofType_error( &self, file_wrapper: &NSFileWrapper, type_name: &NSString, ) -> Result<(), Retained<NSError>>

Source

pub fn readFromData_ofType_error( &self, data: &NSData, type_name: &NSString, ) -> Result<(), Retained<NSError>>

Source

pub fn isEntireFileLoaded(&self) -> bool

Source

pub fn writeToURL_ofType_error( &self, url: &NSURL, type_name: &NSString, ) -> Result<(), Retained<NSError>>

Source

pub fn fileWrapperOfType_error( &self, type_name: &NSString, ) -> Result<Retained<NSFileWrapper>, Retained<NSError>>

Source

pub fn dataOfType_error( &self, type_name: &NSString, ) -> Result<Retained<NSData>, Retained<NSError>>

Source

pub fn unblockUserInteraction(&self)

Source

pub fn autosavingIsImplicitlyCancellable(&self) -> bool

Source

pub fn writeSafelyToURL_ofType_forSaveOperation_error( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, ) -> Result<(), Retained<NSError>>

Source

pub fn writeToURL_ofType_forSaveOperation_originalContentsURL_error( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, absolute_original_contents_url: Option<&NSURL>, ) -> Result<(), Retained<NSError>>

Source

pub fn fileAttributesToWriteToURL_ofType_forSaveOperation_originalContentsURL_error( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, absolute_original_contents_url: Option<&NSURL>, ) -> Result<Retained<NSDictionary<NSString, AnyObject>>, Retained<NSError>>

Source

pub fn keepBackupFile(&self) -> bool

Source

pub fn backupFileURL(&self) -> Option<Retained<NSURL>>

Source

pub unsafe fn saveDocument(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub unsafe fn saveDocumentAs(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub unsafe fn saveDocumentTo(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub unsafe fn saveDocumentWithDelegate_didSaveSelector_contextInfo( &self, delegate: Option<&AnyObject>, did_save_selector: Option<Sel>, context_info: *mut c_void, )

§Safety
  • delegate should be of the correct type.
  • did_save_selector must be a valid selector.
  • context_info must be a valid pointer or null.
Source

pub unsafe fn runModalSavePanelForSaveOperation_delegate_didSaveSelector_contextInfo( &self, save_operation: NSSaveOperationType, delegate: Option<&AnyObject>, did_save_selector: Option<Sel>, context_info: *mut c_void, )

§Safety
  • delegate should be of the correct type.
  • did_save_selector must be a valid selector.
  • context_info must be a valid pointer or null.
Source

pub fn savePanelShowsFileFormatsControl(&self) -> bool

Source

pub fn prepareSavePanel(&self, save_panel: &NSSavePanel) -> bool

Available on crate features NSPanel and NSResponder and NSSavePanel and NSWindow only.
Source

pub fn fileNameExtensionWasHiddenInLastRunSavePanel(&self) -> bool

Source

pub fn fileTypeFromLastRunSavePanel(&self) -> Option<Retained<NSString>>

Source

pub unsafe fn saveToURL_ofType_forSaveOperation_delegate_didSaveSelector_contextInfo( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, delegate: Option<&AnyObject>, did_save_selector: Option<Sel>, context_info: *mut c_void, )

§Safety
  • delegate should be of the correct type.
  • did_save_selector must be a valid selector.
  • context_info must be a valid pointer or null.
Source

pub fn saveToURL_ofType_forSaveOperation_completionHandler( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )

Available on crate feature block2 only.
Source

pub fn canAsynchronouslyWriteToURL_ofType_forSaveOperation( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, ) -> bool

Source

pub fn checkAutosavingSafetyAndReturnError( &self, ) -> Result<(), Retained<NSError>>

Source

pub fn scheduleAutosaving(&self)

Source

pub fn hasUnautosavedChanges(&self) -> bool

Source

pub unsafe fn autosaveDocumentWithDelegate_didAutosaveSelector_contextInfo( &self, delegate: Option<&AnyObject>, did_autosave_selector: Option<Sel>, context_info: *mut c_void, )

§Safety
  • delegate should be of the correct type.
  • did_autosave_selector must be a valid selector.
  • context_info must be a valid pointer or null.
Source

pub fn autosaveWithImplicitCancellability_completionHandler( &self, autosaving_is_implicitly_cancellable: bool, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )

Available on crate feature block2 only.
Source

pub fn autosavesInPlace(mtm: MainThreadMarker) -> bool

Source

pub fn preservesVersions(mtm: MainThreadMarker) -> bool

Source

pub unsafe fn browseDocumentVersions(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub fn isBrowsingVersions(&self) -> bool

Source

pub fn stopBrowsingVersionsWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn()>>, )

Available on crate feature block2 only.
Source

pub fn autosavesDrafts(mtm: MainThreadMarker) -> bool

Source

pub fn autosavingFileType(&self) -> Option<Retained<NSString>>

Source

pub fn autosavedContentsFileURL(&self) -> Option<Retained<NSURL>>

Source

pub fn setAutosavedContentsFileURL( &self, autosaved_contents_file_url: Option<&NSURL>, )

Setter for autosavedContentsFileURL.

This is copied when set.

Source

pub unsafe fn canCloseDocumentWithDelegate_shouldCloseSelector_contextInfo( &self, delegate: &AnyObject, should_close_selector: Option<Sel>, context_info: *mut c_void, )

§Safety
  • delegate should be of the correct type.
  • should_close_selector must be a valid selector.
  • context_info must be a valid pointer or null.
Source

pub fn close(&self)

Source

pub unsafe fn duplicateDocument(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub unsafe fn duplicateDocumentWithDelegate_didDuplicateSelector_contextInfo( &self, delegate: Option<&AnyObject>, did_duplicate_selector: Option<Sel>, context_info: *mut c_void, )

§Safety
  • delegate should be of the correct type.
  • did_duplicate_selector must be a valid selector.
  • context_info must be a valid pointer or null.
Source

pub fn duplicateAndReturnError( &self, ) -> Result<Retained<NSDocument>, Retained<NSError>>

Source

pub unsafe fn renameDocument(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub unsafe fn moveDocumentToUbiquityContainer(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub unsafe fn moveDocument(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub fn moveDocumentWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(Bool)>>, )

Available on crate feature block2 only.
Source

pub fn moveToURL_completionHandler( &self, url: &NSURL, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )

Available on crate feature block2 only.
Source

pub unsafe fn lockDocument(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub unsafe fn unlockDocument(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub fn lockDocumentWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(Bool)>>, )

Available on crate feature block2 only.
Source

pub fn lockWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )

Available on crate feature block2 only.
Source

pub fn unlockDocumentWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(Bool)>>, )

Available on crate feature block2 only.
Source

pub fn unlockWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )

Available on crate feature block2 only.
Source

pub fn isLocked(&self) -> bool

Source

pub unsafe fn runPageLayout(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub unsafe fn runModalPageLayoutWithPrintInfo_delegate_didRunSelector_contextInfo( &self, print_info: &NSPrintInfo, delegate: Option<&AnyObject>, did_run_selector: Option<Sel>, context_info: *mut c_void, )

Available on crate feature NSPrintInfo only.
§Safety
  • delegate should be of the correct type.
  • did_run_selector must be a valid selector.
  • context_info must be a valid pointer or null.
Source

pub fn preparePageLayout(&self, page_layout: &NSPageLayout) -> bool

Available on crate feature NSPageLayout only.
Source

pub fn shouldChangePrintInfo(&self, new_print_info: &NSPrintInfo) -> bool

Available on crate feature NSPrintInfo only.
Source

pub fn printInfo(&self) -> Retained<NSPrintInfo>

Available on crate feature NSPrintInfo only.
Source

pub fn setPrintInfo(&self, print_info: &NSPrintInfo)

Available on crate feature NSPrintInfo only.

Setter for printInfo.

This is copied when set.

Source

pub unsafe fn printDocument(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub unsafe fn printDocumentWithSettings_showPrintPanel_delegate_didPrintSelector_contextInfo( &self, print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>, show_print_panel: bool, delegate: Option<&AnyObject>, did_print_selector: Option<Sel>, context_info: *mut c_void, )

Available on crate feature NSPrintInfo only.
§Safety
  • print_settings generic should be of the correct type.
  • delegate should be of the correct type.
  • did_print_selector must be a valid selector.
  • context_info must be a valid pointer or null.
Source

pub unsafe fn printOperationWithSettings_error( &self, print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>, ) -> Result<Retained<NSPrintOperation>, Retained<NSError>>

Available on crate features NSPrintInfo and NSPrintOperation only.
§Safety

print_settings generic should be of the correct type.

Source

pub unsafe fn runModalPrintOperation_delegate_didRunSelector_contextInfo( &self, print_operation: &NSPrintOperation, delegate: Option<&AnyObject>, did_run_selector: Option<Sel>, context_info: *mut c_void, )

Available on crate feature NSPrintOperation only.
§Safety
  • delegate should be of the correct type.
  • did_run_selector must be a valid selector.
  • context_info must be a valid pointer or null.
Source

pub unsafe fn saveDocumentToPDF(&self, sender: Option<&AnyObject>)

§Safety

sender should be of the correct type.

Source

pub fn PDFPrintOperation(&self) -> Retained<NSPrintOperation>

Available on crate feature NSPrintOperation only.
Source

pub fn allowsDocumentSharing(&self) -> bool

Source

pub fn shareDocumentWithSharingService_completionHandler( &self, sharing_service: &NSSharingService, completion_handler: Option<&DynBlock<dyn Fn(Bool)>>, )

Available on crate features NSSharingService and block2 only.
Source

pub fn prepareSharingServicePicker( &self, sharing_service_picker: &NSSharingServicePicker, )

Available on crate feature NSSharingService only.
Source

pub fn previewRepresentableActivityItems( &self, ) -> Option<Retained<NSArray<ProtocolObject<dyn NSPreviewRepresentableActivityItem>>>>

Available on crate feature NSPreviewRepresentingActivityItem only.
Source

pub fn setPreviewRepresentableActivityItems( &self, preview_representable_activity_items: Option<&NSArray<ProtocolObject<dyn NSPreviewRepresentableActivityItem>>>, )

Available on crate feature NSPreviewRepresentingActivityItem only.

Setter for previewRepresentableActivityItems.

This is copied when set.

Source

pub fn isDocumentEdited(&self) -> bool

Source

pub fn isInViewingMode(&self) -> bool

Source

pub fn updateChangeCount(&self, change: NSDocumentChangeType)

Source

pub fn changeCountTokenForSaveOperation( &self, save_operation: NSSaveOperationType, ) -> Retained<AnyObject>

Source

pub unsafe fn updateChangeCountWithToken_forSaveOperation( &self, change_count_token: &AnyObject, save_operation: NSSaveOperationType, )

§Safety

change_count_token should be of the correct type.

Source

pub fn undoManager(&self) -> Option<Retained<NSUndoManager>>

Source

pub fn setUndoManager(&self, undo_manager: Option<&NSUndoManager>)

Setter for undoManager.

Source

pub fn hasUndoManager(&self) -> bool

Source

pub fn setHasUndoManager(&self, has_undo_manager: bool)

Setter for hasUndoManager.

Source

pub unsafe fn presentError_modalForWindow_delegate_didPresentSelector_contextInfo( &self, error: &NSError, window: &NSWindow, delegate: Option<&AnyObject>, did_present_selector: Option<Sel>, context_info: *mut c_void, )

Available on crate features NSResponder and NSWindow only.
§Safety
  • delegate should be of the correct type.
  • did_present_selector must be a valid selector.
  • context_info must be a valid pointer or null.
Source

pub fn presentError(&self, error: &NSError) -> bool

Source

pub fn willPresentError(&self, error: &NSError) -> Retained<NSError>

Source

pub fn willNotPresentError(&self, error: &NSError)

Source

pub fn makeWindowControllers(&self)

Source

pub fn windowNibName(&self) -> Option<Retained<NSNibName>>

Available on crate feature NSNib only.
Source

pub fn windowControllerWillLoadNib( &self, window_controller: &NSWindowController, )

Available on crate features NSResponder and NSWindowController only.
Source

pub fn windowControllerDidLoadNib(&self, window_controller: &NSWindowController)

Available on crate features NSResponder and NSWindowController only.
Source

pub fn setWindow(&self, window: Option<&NSWindow>)

Available on crate features NSResponder and NSWindow only.
Source

pub fn addWindowController(&self, window_controller: &NSWindowController)

Available on crate features NSResponder and NSWindowController only.
Source

pub fn removeWindowController(&self, window_controller: &NSWindowController)

Available on crate features NSResponder and NSWindowController only.
Source

pub fn showWindows(&self)

Source

pub fn windowControllers(&self) -> Retained<NSArray<NSWindowController>>

Available on crate features NSResponder and NSWindowController only.
Source

pub unsafe fn shouldCloseWindowController_delegate_shouldCloseSelector_contextInfo( &self, window_controller: &NSWindowController, delegate: Option<&AnyObject>, should_close_selector: Option<Sel>, context_info: *mut c_void, )

Available on crate features NSResponder and NSWindowController only.
§Safety
  • delegate should be of the correct type.
  • should_close_selector must be a valid selector.
  • context_info must be a valid pointer or null.
Source

pub fn displayName(&self) -> Retained<NSString>

Source

pub fn defaultDraftName(&self) -> Retained<NSString>

Source

pub fn windowForSheet(&self) -> Option<Retained<NSWindow>>

Available on crate features NSResponder and NSWindow only.
Source

pub fn readableTypes(mtm: MainThreadMarker) -> Retained<NSArray<NSString>>

Source

pub fn writableTypes(mtm: MainThreadMarker) -> Retained<NSArray<NSString>>

Source

pub fn isNativeType(type: &NSString, mtm: MainThreadMarker) -> bool

Source

pub fn writableTypesForSaveOperation( &self, save_operation: NSSaveOperationType, ) -> Retained<NSArray<NSString>>

Source

pub fn fileNameExtensionForType_saveOperation( &self, type_name: &NSString, save_operation: NSSaveOperationType, ) -> Option<Retained<NSString>>

Source

pub fn validateUserInterfaceItem( &self, item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>, ) -> bool

Available on crate feature NSUserInterfaceValidation only.
Source

pub fn usesUbiquitousStorage(mtm: MainThreadMarker) -> bool

Source

pub fn presentedItemURL(&self) -> Option<Retained<NSURL>>

Source

pub fn observedPresentedItemUbiquityAttributes( &self, ) -> Retained<NSSet<NSURLResourceKey>>

Source

pub unsafe fn relinquishPresentedItemToReader( &self, reader: &DynBlock<dyn Fn(*mut DynBlock<dyn Fn()>)>, )

Available on crate feature block2 only.
§Safety

reader block must be sendable.

Source

pub unsafe fn relinquishPresentedItemToWriter( &self, writer: &DynBlock<dyn Fn(*mut DynBlock<dyn Fn()>)>, )

Available on crate feature block2 only.
§Safety

writer block must be sendable.

Source

pub unsafe fn savePresentedItemChangesWithCompletionHandler( &self, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )

Available on crate feature block2 only.
§Safety

completion_handler block must be sendable.

Source

pub unsafe fn accommodatePresentedItemDeletionWithCompletionHandler( &self, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )

Available on crate feature block2 only.
§Safety

completion_handler block must be sendable.

Source

pub fn presentedItemDidMoveToURL(&self, new_url: &NSURL)

Source

pub fn presentedItemDidChange(&self)

Source

pub fn presentedItemDidChangeUbiquityAttributes( &self, attributes: &NSSet<NSURLResourceKey>, )

Source

pub fn presentedItemDidGainVersion(&self, version: &NSFileVersion)

Source

pub fn presentedItemDidLoseVersion(&self, version: &NSFileVersion)

Source

pub fn presentedItemDidResolveConflictVersion(&self, version: &NSFileVersion)

Source§

impl NSDocument

Methods declared on superclass NSObject.

Source

pub fn new(mtm: MainThreadMarker) -> Retained<Self>

Source§

impl NSDocument

NSDeprecated.

Source

pub fn shouldRunSavePanelWithAccessoryView(&self) -> bool

👎Deprecated
Source

pub fn saveToURL_ofType_forSaveOperation_error( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, ) -> Result<(), Retained<NSError>>

👎Deprecated: Use -saveToURL:ofType:forSaveOperation:completionHandler: instead
Source

pub fn dataRepresentationOfType( &self, type: &NSString, ) -> Option<Retained<NSData>>

👎Deprecated
Source

pub fn fileAttributesToWriteToFile_ofType_saveOperation( &self, full_document_path: &NSString, document_type_name: &NSString, save_operation_type: NSSaveOperationType, ) -> Option<Retained<NSDictionary>>

👎Deprecated
Source

pub fn fileName(&self) -> Option<Retained<NSString>>

👎Deprecated
Source

pub fn fileWrapperRepresentationOfType( &self, type: &NSString, ) -> Option<Retained<NSFileWrapper>>

👎Deprecated
Source

pub fn initWithContentsOfFile_ofType( this: Allocated<Self>, absolute_path: &NSString, type_name: &NSString, ) -> Option<Retained<Self>>

👎Deprecated
Source

pub fn initWithContentsOfURL_ofType( this: Allocated<Self>, url: &NSURL, type_name: &NSString, ) -> Option<Retained<Self>>

👎Deprecated
Source

pub fn loadDataRepresentation_ofType( &self, data: &NSData, type: &NSString, ) -> bool

👎Deprecated
Source

pub fn loadFileWrapperRepresentation_ofType( &self, wrapper: &NSFileWrapper, type: &NSString, ) -> bool

👎Deprecated
Source

pub fn printShowingPrintPanel(&self, flag: bool)

👎Deprecated
Source

pub fn readFromFile_ofType(&self, file_name: &NSString, type: &NSString) -> bool

👎Deprecated
Source

pub fn readFromURL_ofType(&self, url: &NSURL, type: &NSString) -> bool

👎Deprecated
Source

pub fn revertToSavedFromFile_ofType( &self, file_name: &NSString, type: &NSString, ) -> bool

👎Deprecated
Source

pub fn revertToSavedFromURL_ofType(&self, url: &NSURL, type: &NSString) -> bool

👎Deprecated
Source

pub fn runModalPageLayoutWithPrintInfo( &self, print_info: &NSPrintInfo, ) -> NSInteger

👎Deprecated
Available on crate feature NSPrintInfo only.
Source

pub unsafe fn saveToFile_saveOperation_delegate_didSaveSelector_contextInfo( &self, file_name: &NSString, save_operation: NSSaveOperationType, delegate: Option<&AnyObject>, did_save_selector: Option<Sel>, context_info: *mut c_void, )

👎Deprecated
§Safety
  • delegate should be of the correct type.
  • did_save_selector must be a valid selector.
  • context_info must be a valid pointer or null.
Source

pub fn setFileName(&self, file_name: Option<&NSString>)

👎Deprecated
Source

pub fn writeToFile_ofType(&self, file_name: &NSString, type: &NSString) -> bool

👎Deprecated
Source

pub fn writeToFile_ofType_originalFile_saveOperation( &self, full_document_path: &NSString, document_type_name: &NSString, full_original_document_path: Option<&NSString>, save_operation_type: NSSaveOperationType, ) -> bool

👎Deprecated
Source

pub fn writeToURL_ofType(&self, url: &NSURL, type: &NSString) -> bool

👎Deprecated
Source

pub fn writeWithBackupToFile_ofType_saveOperation( &self, full_document_path: &NSString, document_type_name: &NSString, save_operation_type: NSSaveOperationType, ) -> bool

👎Deprecated
Source§

impl NSDocument

NSScripting.

Source

pub fn lastComponentOfFileName(&self) -> Retained<NSString>

Available on crate feature NSDocumentScripting only.
Source

pub fn setLastComponentOfFileName(&self, last_component_of_file_name: &NSString)

Available on crate feature NSDocumentScripting only.

Setter for lastComponentOfFileName.

This is copied when set.

Source

pub fn handleSaveScriptCommand( &self, command: &NSScriptCommand, ) -> Option<Retained<AnyObject>>

Available on crate feature NSDocumentScripting only.
Source

pub fn handleCloseScriptCommand( &self, command: &NSCloseCommand, ) -> Option<Retained<AnyObject>>

Available on crate feature NSDocumentScripting only.
Source

pub fn handlePrintScriptCommand( &self, command: &NSScriptCommand, ) -> Option<Retained<AnyObject>>

Available on crate feature NSDocumentScripting only.
Source

pub fn objectSpecifier(&self) -> Retained<NSScriptObjectSpecifier>

Available on crate feature NSDocumentScripting only.
Source§

impl NSDocument

NSUserActivity.

Source

pub fn userActivity(&self) -> Option<Retained<NSUserActivity>>

Available on crate feature NSUserActivity only.
Source

pub fn setUserActivity(&self, user_activity: Option<&NSUserActivity>)

Available on crate feature NSUserActivity only.

Setter for userActivity.

Source

pub fn updateUserActivityState(&self, activity: &NSUserActivity)

Available on crate feature NSUserActivity only.
Source§

impl NSDocument

NSRestorableState.

Source

pub unsafe fn restoreDocumentWindowWithIdentifier_state_completionHandler( &self, identifier: &NSUserInterfaceItemIdentifier, state: &NSCoder, completion_handler: &DynBlock<dyn Fn(*mut NSWindow, *mut NSError)>, )

Available on crate features NSWindowRestoration and NSResponder and NSUserInterfaceItemIdentification and NSWindow and block2 only.
§Safety

state possibly has further requirements.

Source

pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder)

Available on crate feature NSWindowRestoration only.
§Safety

coder possibly has further requirements.

Source

pub unsafe fn encodeRestorableStateWithCoder_backgroundQueue( &self, coder: &NSCoder, queue: &NSOperationQueue, )

Available on crate feature NSWindowRestoration only.
§Safety
  • coder possibly has further requirements.
  • queue possibly has additional threading requirements.
Source

pub unsafe fn restoreStateWithCoder(&self, coder: &NSCoder)

Available on crate feature NSWindowRestoration only.
§Safety

coder possibly has further requirements.

Source

pub fn invalidateRestorableState(&self)

Available on crate feature NSWindowRestoration only.
Source

pub fn restorableStateKeyPaths( mtm: MainThreadMarker, ) -> Retained<NSArray<NSString>>

Available on crate feature NSWindowRestoration only.
Source

pub fn allowedClassesForRestorableStateKeyPath( key_path: &NSString, mtm: MainThreadMarker, ) -> Retained<NSArray<AnyClass>>

Available on crate feature NSWindowRestoration only.

Methods from Deref<Target = NSObject>§

Source

pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !

Handle messages the object doesn’t recognize.

See Apple’s documentation for details.

Methods from Deref<Target = AnyObject>§

Source

pub fn class(&self) -> &'static AnyClass

Available on crate feature NSAccessibilityConstants only.

Dynamically find the class of this object.

§Panics

May panic if the object is invalid (which may be the case for objects returned from unavailable init/new methods).

§Example

Check that an instance of NSObject has the precise class NSObject.

use objc2::ClassType;
use objc2::runtime::NSObject;

let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Source

pub unsafe fn get_ivar<T>(&self, name: &str) -> &T
where T: Encode,

👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
Available on crate feature NSAccessibilityConstants only.

Use Ivar::load instead.

§Safety

The object must have an instance variable with the given name, and it must be of type T.

See Ivar::load_ptr for details surrounding this.

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: DowncastTarget,

Available on crate feature NSAccessibilityConstants only.

Attempt to downcast the object to a class of type T.

This is the reference-variant. Use Retained::downcast if you want to convert a retained object to another type.

§Mutable classes

Some classes have immutable and mutable variants, such as NSString and NSMutableString.

When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.

So using this method to convert a NSString to a NSMutableString, while not unsound, is generally frowned upon unless you created the string yourself, or the API explicitly documents the string to be mutable.

See Apple’s documentation on mutability and on isKindOfClass: for more details.

§Generic classes

Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.

You can, however, safely downcast to generic collections where all the type-parameters are AnyObject.

§Panics

This works internally by calling isKindOfClass:. That means that the object must have the instance method of that name, and an exception will be thrown (if CoreFoundation is linked) or the process will abort if that is not the case. In the vast majority of cases, you don’t need to worry about this, since both root objects NSObject and NSProxy implement this method.

§Examples

Cast an NSString back and forth from NSObject.

use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};

let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();

Try (and fail) to cast an NSObject to an NSString.

use objc2_foundation::{NSObject, NSString};

let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());

Try to cast to an array of strings.

use objc2_foundation::{NSArray, NSObject, NSString};

let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();

This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.

Downcast when processing each element instead.

use objc2_foundation::{NSArray, NSObject, NSString};

let arr = NSArray::from_retained_slice(&[NSObject::new()]);

for elem in arr {
    if let Some(data) = elem.downcast_ref::<NSString>() {
        // handle `data`
    }
}

Trait Implementations§

Source§

impl AsRef<AnyObject> for NSDocument

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<NSDocument> for NSDocument

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<NSDocument> for NSPersistentDocument

Available on crate feature NSPersistentDocument only.
Source§

fn as_ref(&self) -> &NSDocument

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<NSObject> for NSDocument

Source§

fn as_ref(&self) -> &NSObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for NSDocument

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<NSDocument> for NSPersistentDocument

Available on crate feature NSPersistentDocument only.
Source§

fn borrow(&self) -> &NSDocument

Immutably borrows from an owned value. Read more
Source§

impl Borrow<NSObject> for NSDocument

Source§

fn borrow(&self) -> &NSObject

Immutably borrows from an owned value. Read more
Source§

impl ClassType for NSDocument

Source§

const NAME: &'static str = "NSDocument"

The name of the Objective-C class that this type represents. Read more
Source§

type Super = NSObject

The superclass of this class. Read more
Source§

type ThreadKind = dyn MainThreadOnly

Whether the type can be used from any thread, or from only the main thread. Read more
Source§

fn class() -> &'static AnyClass

Get a reference to the Objective-C class that this type represents. Read more
Source§

fn as_super(&self) -> &Self::Super

Get an immutable reference to the superclass.
Source§

impl Debug for NSDocument

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for NSDocument

Source§

type Target = NSObject

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for NSDocument

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for NSDocument

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl NSEditorRegistration for NSDocument

Source§

fn objectDidBeginEditing(&self, editor: &ProtocolObject<dyn NSEditor>)
where Self: Sized + Message,

Available on crate feature NSKeyValueBinding only.
Source§

fn objectDidEndEditing(&self, editor: &ProtocolObject<dyn NSEditor>)
where Self: Sized + Message,

Available on crate feature NSKeyValueBinding only.
Source§

impl NSFilePresenter for NSDocument

Source§

fn presentedItemURL(&self) -> Option<Retained<NSURL>>
where Self: Sized + Message,

Source§

fn presentedItemOperationQueue(&self) -> Retained<NSOperationQueue>
where Self: Sized + Message,

Source§

fn primaryPresentedItemURL(&self) -> Option<Retained<NSURL>>
where Self: Sized + Message,

Source§

fn presentedItemDidMoveToURL(&self, new_url: &NSURL)
where Self: Sized + Message,

Source§

fn presentedItemDidChange(&self)
where Self: Sized + Message,

Source§

fn presentedItemDidChangeUbiquityAttributes(&self, attributes: &NSSet<NSString>)
where Self: Sized + Message,

Source§

fn observedPresentedItemUbiquityAttributes(&self) -> Retained<NSSet<NSString>>
where Self: Sized + Message,

Source§

fn presentedItemDidGainVersion(&self, version: &NSFileVersion)
where Self: Sized + Message,

Source§

fn presentedItemDidLoseVersion(&self, version: &NSFileVersion)
where Self: Sized + Message,

Source§

fn presentedItemDidResolveConflictVersion(&self, version: &NSFileVersion)
where Self: Sized + Message,

Source§

fn presentedSubitemDidAppearAtURL(&self, url: &NSURL)
where Self: Sized + Message,

Source§

fn presentedSubitemAtURL_didMoveToURL(&self, old_url: &NSURL, new_url: &NSURL)
where Self: Sized + Message,

Source§

fn presentedSubitemDidChangeAtURL(&self, url: &NSURL)
where Self: Sized + Message,

Source§

fn presentedSubitemAtURL_didGainVersion( &self, url: &NSURL, version: &NSFileVersion, )
where Self: Sized + Message,

Source§

fn presentedSubitemAtURL_didLoseVersion( &self, url: &NSURL, version: &NSFileVersion, )
where Self: Sized + Message,

Source§

fn presentedSubitemAtURL_didResolveConflictVersion( &self, url: &NSURL, version: &NSFileVersion, )
where Self: Sized + Message,

Source§

impl NSMenuItemValidation for NSDocument

Source§

fn validateMenuItem(&self, menu_item: &NSMenuItem) -> bool
where Self: Sized + Message,

Available on crate features NSMenu and NSMenuItem only.
Source§

impl NSObjectProtocol for NSDocument

Source§

fn isEqual(&self, other: Option<&AnyObject>) -> bool
where Self: Sized + Message,

Check whether the object is equal to an arbitrary other object. Read more
Source§

fn hash(&self) -> usize
where Self: Sized + Message,

An integer that can be used as a table address in a hash table structure. Read more
Source§

fn isKindOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of the class, or one of its subclasses. Read more
Source§

fn is_kind_of<T>(&self) -> bool
where T: ClassType, Self: Sized + Message,

👎Deprecated: use isKindOfClass directly, or cast your objects with AnyObject::downcast_ref
Check if the object is an instance of the class type, or one of its subclasses. Read more
Source§

fn isMemberOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of a specific class, without checking subclasses. Read more
Source§

fn respondsToSelector(&self, aSelector: Sel) -> bool
where Self: Sized + Message,

Check whether the object implements or inherits a method with the given selector. Read more
Source§

fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
where Self: Sized + Message,

Check whether the object conforms to a given protocol. Read more
Source§

fn description(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object. Read more
Source§

fn debugDescription(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object to use when debugging. Read more
Source§

fn isProxy(&self) -> bool
where Self: Sized + Message,

Check whether the receiver is a subclass of the NSProxy root class instead of the usual NSObject. Read more
Source§

fn retainCount(&self) -> usize
where Self: Sized + Message,

The reference count of the object. Read more
Source§

impl NSUserActivityRestoring for NSDocument

Available on crate feature NSUserActivity only.
Source§

fn restoreUserActivityState(&self, user_activity: &NSUserActivity)
where Self: Sized + Message,

Source§

impl NSUserInterfaceValidations for NSDocument

Source§

fn validateUserInterfaceItem( &self, item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>, ) -> bool
where Self: Sized + Message,

Available on crate feature NSUserInterfaceValidation only.
Source§

impl PartialEq for NSDocument

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for NSDocument

Source§

const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl DowncastTarget for NSDocument

Source§

impl Eq for NSDocument

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'a, T> MainThreadOnly for T
where T: ClassType<ThreadKind = dyn MainThreadOnly + 'a> + ?Sized,

Source§

fn mtm(&self) -> MainThreadMarker

Get a MainThreadMarker from the main-thread-only object. Read more
Source§

fn alloc(mtm: MainThreadMarker) -> Allocated<Self>
where Self: Sized + ClassType,

Allocate a new instance of the class on the main thread. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,