pub struct NSPersistentDocument { /* private fields */ }NSDocument and NSPersistentDocument only.Expand description
Implementations§
Source§impl NSPersistentDocument
impl NSPersistentDocument
Sourcepub unsafe fn configurePersistentStoreCoordinatorForURL_ofType_modelConfiguration_storeOptions_error(
&self,
url: &NSURL,
file_type: &NSString,
configuration: Option<&NSString>,
store_options: Option<&NSDictionary<NSString, AnyObject>>,
) -> Result<(), Retained<NSError>>
pub unsafe fn configurePersistentStoreCoordinatorForURL_ofType_modelConfiguration_storeOptions_error( &self, url: &NSURL, file_type: &NSString, configuration: Option<&NSString>, store_options: Option<&NSDictionary<NSString, AnyObject>>, ) -> Result<(), Retained<NSError>>
§Safety
store_options generic should be of the correct type.
pub fn persistentStoreTypeForFileType( &self, file_type: &NSString, ) -> Retained<NSString>
pub fn writeToURL_ofType_forSaveOperation_originalContentsURL_error( &self, absolute_url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, absolute_original_contents_url: Option<&NSURL>, ) -> Result<(), Retained<NSError>>
pub fn readFromURL_ofType_error( &self, absolute_url: &NSURL, type_name: &NSString, ) -> Result<(), Retained<NSError>>
pub fn revertToContentsOfURL_ofType_error( &self, in_absolute_url: &NSURL, in_type_name: &NSString, ) -> Result<(), Retained<NSError>>
Source§impl NSPersistentDocument
Methods declared on superclass NSDocument.
impl NSPersistentDocument
Methods declared on superclass NSDocument.
pub fn init(this: Allocated<Self>) -> Retained<Self>
pub fn initWithType_error( this: Allocated<Self>, type_name: &NSString, ) -> Result<Retained<Self>, Retained<NSError>>
pub fn initWithContentsOfURL_ofType_error( this: Allocated<Self>, url: &NSURL, type_name: &NSString, ) -> Result<Retained<Self>, Retained<NSError>>
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§impl NSPersistentDocument
Methods declared on superclass NSObject.
impl NSPersistentDocument
Methods declared on superclass NSObject.
pub fn new(mtm: MainThreadMarker) -> Retained<Self>
Methods from Deref<Target = NSDocument>§
pub fn fileType(&self) -> Option<Retained<NSString>>
Sourcepub fn setFileType(&self, file_type: Option<&NSString>)
pub fn setFileType(&self, file_type: Option<&NSString>)
pub fn fileURL(&self) -> Option<Retained<NSURL>>
Sourcepub fn setFileURL(&self, file_url: Option<&NSURL>)
pub fn setFileURL(&self, file_url: Option<&NSURL>)
pub fn fileModificationDate(&self) -> Option<Retained<NSDate>>
Sourcepub fn setFileModificationDate(&self, file_modification_date: Option<&NSDate>)
pub fn setFileModificationDate(&self, file_modification_date: Option<&NSDate>)
Setter for fileModificationDate.
This is copied when set.
pub fn isDraft(&self) -> bool
pub fn performActivityWithSynchronousWaiting_usingBlock( &self, wait_synchronously: bool, block: &DynBlock<dyn Fn(NonNull<DynBlock<dyn Fn()>>)>, )
block2 only.pub fn continueActivityUsingBlock(&self, block: &DynBlock<dyn Fn() + '_>)
block2 only.pub fn continueAsynchronousWorkOnMainThreadUsingBlock( &self, block: &DynBlock<dyn Fn()>, )
block2 only.pub fn performSynchronousFileAccessUsingBlock( &self, block: &DynBlock<dyn Fn() + '_>, )
block2 only.pub fn performAsynchronousFileAccessUsingBlock( &self, block: &DynBlock<dyn Fn(NonNull<DynBlock<dyn Fn()>>)>, )
block2 only.Sourcepub unsafe fn revertDocumentToSaved(&self, sender: Option<&AnyObject>)
pub unsafe fn revertDocumentToSaved(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
pub fn revertToContentsOfURL_ofType_error( &self, url: &NSURL, type_name: &NSString, ) -> Result<(), Retained<NSError>>
pub fn readFromURL_ofType_error( &self, url: &NSURL, type_name: &NSString, ) -> Result<(), Retained<NSError>>
pub fn readFromFileWrapper_ofType_error( &self, file_wrapper: &NSFileWrapper, type_name: &NSString, ) -> Result<(), Retained<NSError>>
pub fn readFromData_ofType_error( &self, data: &NSData, type_name: &NSString, ) -> Result<(), Retained<NSError>>
pub fn isEntireFileLoaded(&self) -> bool
pub fn writeToURL_ofType_error( &self, url: &NSURL, type_name: &NSString, ) -> Result<(), Retained<NSError>>
pub fn fileWrapperOfType_error( &self, type_name: &NSString, ) -> Result<Retained<NSFileWrapper>, Retained<NSError>>
pub fn dataOfType_error( &self, type_name: &NSString, ) -> Result<Retained<NSData>, Retained<NSError>>
pub fn unblockUserInteraction(&self)
pub fn autosavingIsImplicitlyCancellable(&self) -> bool
pub fn writeSafelyToURL_ofType_forSaveOperation_error( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, ) -> Result<(), Retained<NSError>>
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>>
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>>
pub fn keepBackupFile(&self) -> bool
pub fn backupFileURL(&self) -> Option<Retained<NSURL>>
Sourcepub unsafe fn saveDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn saveDocument(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
Sourcepub unsafe fn saveDocumentAs(&self, sender: Option<&AnyObject>)
pub unsafe fn saveDocumentAs(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
Sourcepub unsafe fn saveDocumentTo(&self, sender: Option<&AnyObject>)
pub unsafe fn saveDocumentTo(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
Sourcepub unsafe fn saveDocumentWithDelegate_didSaveSelector_contextInfo(
&self,
delegate: Option<&AnyObject>,
did_save_selector: Option<Sel>,
context_info: *mut c_void,
)
pub unsafe fn saveDocumentWithDelegate_didSaveSelector_contextInfo( &self, delegate: Option<&AnyObject>, did_save_selector: Option<Sel>, context_info: *mut c_void, )
§Safety
delegateshould be of the correct type.did_save_selectormust be a valid selector.context_infomust be a valid pointer or null.
Sourcepub unsafe fn runModalSavePanelForSaveOperation_delegate_didSaveSelector_contextInfo(
&self,
save_operation: NSSaveOperationType,
delegate: Option<&AnyObject>,
did_save_selector: Option<Sel>,
context_info: *mut c_void,
)
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
delegateshould be of the correct type.did_save_selectormust be a valid selector.context_infomust be a valid pointer or null.
pub fn savePanelShowsFileFormatsControl(&self) -> bool
pub fn prepareSavePanel(&self, save_panel: &NSSavePanel) -> bool
NSPanel and NSResponder and NSSavePanel and NSWindow only.pub fn fileNameExtensionWasHiddenInLastRunSavePanel(&self) -> bool
pub fn fileTypeFromLastRunSavePanel(&self) -> Option<Retained<NSString>>
Sourcepub 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,
)
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
delegateshould be of the correct type.did_save_selectormust be a valid selector.context_infomust be a valid pointer or null.
pub fn saveToURL_ofType_forSaveOperation_completionHandler( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )
block2 only.pub fn canAsynchronouslyWriteToURL_ofType_forSaveOperation( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, ) -> bool
pub fn checkAutosavingSafetyAndReturnError( &self, ) -> Result<(), Retained<NSError>>
pub fn scheduleAutosaving(&self)
pub fn hasUnautosavedChanges(&self) -> bool
Sourcepub unsafe fn autosaveDocumentWithDelegate_didAutosaveSelector_contextInfo(
&self,
delegate: Option<&AnyObject>,
did_autosave_selector: Option<Sel>,
context_info: *mut c_void,
)
pub unsafe fn autosaveDocumentWithDelegate_didAutosaveSelector_contextInfo( &self, delegate: Option<&AnyObject>, did_autosave_selector: Option<Sel>, context_info: *mut c_void, )
§Safety
delegateshould be of the correct type.did_autosave_selectormust be a valid selector.context_infomust be a valid pointer or null.
pub fn autosaveWithImplicitCancellability_completionHandler( &self, autosaving_is_implicitly_cancellable: bool, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )
block2 only.Sourcepub unsafe fn browseDocumentVersions(&self, sender: Option<&AnyObject>)
pub unsafe fn browseDocumentVersions(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
pub fn isBrowsingVersions(&self) -> bool
pub fn stopBrowsingVersionsWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn()>>, )
block2 only.pub fn autosavingFileType(&self) -> Option<Retained<NSString>>
pub fn autosavedContentsFileURL(&self) -> Option<Retained<NSURL>>
Sourcepub fn setAutosavedContentsFileURL(
&self,
autosaved_contents_file_url: Option<&NSURL>,
)
pub fn setAutosavedContentsFileURL( &self, autosaved_contents_file_url: Option<&NSURL>, )
Setter for autosavedContentsFileURL.
This is copied when set.
Sourcepub unsafe fn canCloseDocumentWithDelegate_shouldCloseSelector_contextInfo(
&self,
delegate: &AnyObject,
should_close_selector: Option<Sel>,
context_info: *mut c_void,
)
pub unsafe fn canCloseDocumentWithDelegate_shouldCloseSelector_contextInfo( &self, delegate: &AnyObject, should_close_selector: Option<Sel>, context_info: *mut c_void, )
§Safety
delegateshould be of the correct type.should_close_selectormust be a valid selector.context_infomust be a valid pointer or null.
pub fn close(&self)
Sourcepub unsafe fn duplicateDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn duplicateDocument(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
Sourcepub unsafe fn duplicateDocumentWithDelegate_didDuplicateSelector_contextInfo(
&self,
delegate: Option<&AnyObject>,
did_duplicate_selector: Option<Sel>,
context_info: *mut c_void,
)
pub unsafe fn duplicateDocumentWithDelegate_didDuplicateSelector_contextInfo( &self, delegate: Option<&AnyObject>, did_duplicate_selector: Option<Sel>, context_info: *mut c_void, )
§Safety
delegateshould be of the correct type.did_duplicate_selectormust be a valid selector.context_infomust be a valid pointer or null.
pub fn duplicateAndReturnError( &self, ) -> Result<Retained<NSDocument>, Retained<NSError>>
Sourcepub unsafe fn renameDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn renameDocument(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
Sourcepub unsafe fn moveDocumentToUbiquityContainer(&self, sender: Option<&AnyObject>)
pub unsafe fn moveDocumentToUbiquityContainer(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
Sourcepub unsafe fn moveDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn moveDocument(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
pub fn moveDocumentWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(Bool)>>, )
block2 only.pub fn moveToURL_completionHandler( &self, url: &NSURL, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )
block2 only.Sourcepub unsafe fn lockDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn lockDocument(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
Sourcepub unsafe fn unlockDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn unlockDocument(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
pub fn lockDocumentWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(Bool)>>, )
block2 only.pub fn lockWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )
block2 only.pub fn unlockDocumentWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(Bool)>>, )
block2 only.pub fn unlockWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )
block2 only.pub fn isLocked(&self) -> bool
Sourcepub unsafe fn runPageLayout(&self, sender: Option<&AnyObject>)
pub unsafe fn runPageLayout(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
Sourcepub 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.
pub unsafe fn runModalPageLayoutWithPrintInfo_delegate_didRunSelector_contextInfo( &self, print_info: &NSPrintInfo, delegate: Option<&AnyObject>, did_run_selector: Option<Sel>, context_info: *mut c_void, )
NSPrintInfo only.§Safety
delegateshould be of the correct type.did_run_selectormust be a valid selector.context_infomust be a valid pointer or null.
pub fn preparePageLayout(&self, page_layout: &NSPageLayout) -> bool
NSPageLayout only.pub fn shouldChangePrintInfo(&self, new_print_info: &NSPrintInfo) -> bool
NSPrintInfo only.pub fn printInfo(&self) -> Retained<NSPrintInfo>
NSPrintInfo only.Sourcepub fn setPrintInfo(&self, print_info: &NSPrintInfo)
Available on crate feature NSPrintInfo only.
pub fn setPrintInfo(&self, print_info: &NSPrintInfo)
NSPrintInfo only.Sourcepub unsafe fn printDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn printDocument(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
Sourcepub 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.
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, )
NSPrintInfo only.§Safety
print_settingsgeneric should be of the correct type.delegateshould be of the correct type.did_print_selectormust be a valid selector.context_infomust be a valid pointer or null.
Sourcepub unsafe fn printOperationWithSettings_error(
&self,
print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>,
) -> Result<Retained<NSPrintOperation>, Retained<NSError>>
Available on crate features NSPrintInfo and NSPrintOperation only.
pub unsafe fn printOperationWithSettings_error( &self, print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>, ) -> Result<Retained<NSPrintOperation>, Retained<NSError>>
NSPrintInfo and NSPrintOperation only.§Safety
print_settings generic should be of the correct type.
Sourcepub 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.
pub unsafe fn runModalPrintOperation_delegate_didRunSelector_contextInfo( &self, print_operation: &NSPrintOperation, delegate: Option<&AnyObject>, did_run_selector: Option<Sel>, context_info: *mut c_void, )
NSPrintOperation only.§Safety
delegateshould be of the correct type.did_run_selectormust be a valid selector.context_infomust be a valid pointer or null.
Sourcepub unsafe fn saveDocumentToPDF(&self, sender: Option<&AnyObject>)
pub unsafe fn saveDocumentToPDF(&self, sender: Option<&AnyObject>)
§Safety
sender should be of the correct type.
pub fn PDFPrintOperation(&self) -> Retained<NSPrintOperation>
NSPrintOperation only.pub fn allowsDocumentSharing(&self) -> bool
NSSharingService and block2 only.pub fn prepareSharingServicePicker( &self, sharing_service_picker: &NSSharingServicePicker, )
NSSharingService only.pub fn previewRepresentableActivityItems( &self, ) -> Option<Retained<NSArray<ProtocolObject<dyn NSPreviewRepresentableActivityItem>>>>
NSPreviewRepresentingActivityItem only.Sourcepub fn setPreviewRepresentableActivityItems(
&self,
preview_representable_activity_items: Option<&NSArray<ProtocolObject<dyn NSPreviewRepresentableActivityItem>>>,
)
Available on crate feature NSPreviewRepresentingActivityItem only.
pub fn setPreviewRepresentableActivityItems( &self, preview_representable_activity_items: Option<&NSArray<ProtocolObject<dyn NSPreviewRepresentableActivityItem>>>, )
NSPreviewRepresentingActivityItem only.Setter for previewRepresentableActivityItems.
This is copied when set.
pub fn isDocumentEdited(&self) -> bool
pub fn isInViewingMode(&self) -> bool
pub fn updateChangeCount(&self, change: NSDocumentChangeType)
pub fn changeCountTokenForSaveOperation( &self, save_operation: NSSaveOperationType, ) -> Retained<AnyObject>
Sourcepub unsafe fn updateChangeCountWithToken_forSaveOperation(
&self,
change_count_token: &AnyObject,
save_operation: NSSaveOperationType,
)
pub unsafe fn updateChangeCountWithToken_forSaveOperation( &self, change_count_token: &AnyObject, save_operation: NSSaveOperationType, )
§Safety
change_count_token should be of the correct type.
pub fn undoManager(&self) -> Option<Retained<NSUndoManager>>
Sourcepub fn setUndoManager(&self, undo_manager: Option<&NSUndoManager>)
pub fn setUndoManager(&self, undo_manager: Option<&NSUndoManager>)
Setter for undoManager.
pub fn hasUndoManager(&self) -> bool
Sourcepub fn setHasUndoManager(&self, has_undo_manager: bool)
pub fn setHasUndoManager(&self, has_undo_manager: bool)
Setter for hasUndoManager.
Sourcepub 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.
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, )
NSResponder and NSWindow only.§Safety
delegateshould be of the correct type.did_present_selectormust be a valid selector.context_infomust be a valid pointer or null.
pub fn presentError(&self, error: &NSError) -> bool
pub fn willPresentError(&self, error: &NSError) -> Retained<NSError>
pub fn willNotPresentError(&self, error: &NSError)
pub fn makeWindowControllers(&self)
pub fn windowNibName(&self) -> Option<Retained<NSNibName>>
NSNib only.pub fn windowControllerWillLoadNib( &self, window_controller: &NSWindowController, )
NSResponder and NSWindowController only.pub fn windowControllerDidLoadNib(&self, window_controller: &NSWindowController)
NSResponder and NSWindowController only.pub fn setWindow(&self, window: Option<&NSWindow>)
NSResponder and NSWindow only.pub fn addWindowController(&self, window_controller: &NSWindowController)
NSResponder and NSWindowController only.pub fn removeWindowController(&self, window_controller: &NSWindowController)
NSResponder and NSWindowController only.pub fn showWindows(&self)
pub fn windowControllers(&self) -> Retained<NSArray<NSWindowController>>
NSResponder and NSWindowController only.Sourcepub 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.
pub unsafe fn shouldCloseWindowController_delegate_shouldCloseSelector_contextInfo( &self, window_controller: &NSWindowController, delegate: Option<&AnyObject>, should_close_selector: Option<Sel>, context_info: *mut c_void, )
NSResponder and NSWindowController only.§Safety
delegateshould be of the correct type.should_close_selectormust be a valid selector.context_infomust be a valid pointer or null.
pub fn displayName(&self) -> Retained<NSString>
pub fn defaultDraftName(&self) -> Retained<NSString>
pub fn windowForSheet(&self) -> Option<Retained<NSWindow>>
NSResponder and NSWindow only.pub fn writableTypesForSaveOperation( &self, save_operation: NSSaveOperationType, ) -> Retained<NSArray<NSString>>
pub fn fileNameExtensionForType_saveOperation( &self, type_name: &NSString, save_operation: NSSaveOperationType, ) -> Option<Retained<NSString>>
pub fn validateUserInterfaceItem( &self, item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>, ) -> bool
NSUserInterfaceValidation only.pub fn presentedItemURL(&self) -> Option<Retained<NSURL>>
pub fn observedPresentedItemUbiquityAttributes( &self, ) -> Retained<NSSet<NSURLResourceKey>>
Sourcepub unsafe fn relinquishPresentedItemToReader(
&self,
reader: &DynBlock<dyn Fn(*mut DynBlock<dyn Fn()>)>,
)
Available on crate feature block2 only.
pub unsafe fn relinquishPresentedItemToReader( &self, reader: &DynBlock<dyn Fn(*mut DynBlock<dyn Fn()>)>, )
block2 only.§Safety
reader block must be sendable.
Sourcepub unsafe fn relinquishPresentedItemToWriter(
&self,
writer: &DynBlock<dyn Fn(*mut DynBlock<dyn Fn()>)>,
)
Available on crate feature block2 only.
pub unsafe fn relinquishPresentedItemToWriter( &self, writer: &DynBlock<dyn Fn(*mut DynBlock<dyn Fn()>)>, )
block2 only.§Safety
writer block must be sendable.
Sourcepub unsafe fn savePresentedItemChangesWithCompletionHandler(
&self,
completion_handler: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate feature block2 only.
pub unsafe fn savePresentedItemChangesWithCompletionHandler( &self, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )
block2 only.§Safety
completion_handler block must be sendable.
Sourcepub unsafe fn accommodatePresentedItemDeletionWithCompletionHandler(
&self,
completion_handler: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate feature block2 only.
pub unsafe fn accommodatePresentedItemDeletionWithCompletionHandler( &self, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )
block2 only.§Safety
completion_handler block must be sendable.
pub fn presentedItemDidMoveToURL(&self, new_url: &NSURL)
pub fn presentedItemDidChange(&self)
pub fn presentedItemDidChangeUbiquityAttributes( &self, attributes: &NSSet<NSURLResourceKey>, )
pub fn presentedItemDidGainVersion(&self, version: &NSFileVersion)
pub fn presentedItemDidLoseVersion(&self, version: &NSFileVersion)
pub fn presentedItemDidResolveConflictVersion(&self, version: &NSFileVersion)
pub fn shouldRunSavePanelWithAccessoryView(&self) -> bool
pub fn saveToURL_ofType_forSaveOperation_error( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, ) -> Result<(), Retained<NSError>>
pub fn dataRepresentationOfType( &self, type: &NSString, ) -> Option<Retained<NSData>>
pub fn fileAttributesToWriteToFile_ofType_saveOperation( &self, full_document_path: &NSString, document_type_name: &NSString, save_operation_type: NSSaveOperationType, ) -> Option<Retained<NSDictionary>>
pub fn fileName(&self) -> Option<Retained<NSString>>
pub fn fileWrapperRepresentationOfType( &self, type: &NSString, ) -> Option<Retained<NSFileWrapper>>
pub fn loadDataRepresentation_ofType( &self, data: &NSData, type: &NSString, ) -> bool
pub fn loadFileWrapperRepresentation_ofType( &self, wrapper: &NSFileWrapper, type: &NSString, ) -> bool
pub fn printShowingPrintPanel(&self, flag: bool)
pub fn readFromFile_ofType(&self, file_name: &NSString, type: &NSString) -> bool
pub fn readFromURL_ofType(&self, url: &NSURL, type: &NSString) -> bool
pub fn revertToSavedFromFile_ofType( &self, file_name: &NSString, type: &NSString, ) -> bool
pub fn revertToSavedFromURL_ofType(&self, url: &NSURL, type: &NSString) -> bool
pub fn runModalPageLayoutWithPrintInfo( &self, print_info: &NSPrintInfo, ) -> NSInteger
NSPrintInfo only.Sourcepub 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
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, )
§Safety
delegateshould be of the correct type.did_save_selectormust be a valid selector.context_infomust be a valid pointer or null.
pub fn setFileName(&self, file_name: Option<&NSString>)
pub fn writeToFile_ofType(&self, file_name: &NSString, type: &NSString) -> bool
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
pub fn writeToURL_ofType(&self, url: &NSURL, type: &NSString) -> bool
pub fn writeWithBackupToFile_ofType_saveOperation( &self, full_document_path: &NSString, document_type_name: &NSString, save_operation_type: NSSaveOperationType, ) -> bool
pub fn lastComponentOfFileName(&self) -> Retained<NSString>
NSDocumentScripting only.Sourcepub fn setLastComponentOfFileName(&self, last_component_of_file_name: &NSString)
Available on crate feature NSDocumentScripting only.
pub fn setLastComponentOfFileName(&self, last_component_of_file_name: &NSString)
NSDocumentScripting only.Setter for lastComponentOfFileName.
This is copied when set.
pub fn handleSaveScriptCommand( &self, command: &NSScriptCommand, ) -> Option<Retained<AnyObject>>
NSDocumentScripting only.pub fn handleCloseScriptCommand( &self, command: &NSCloseCommand, ) -> Option<Retained<AnyObject>>
NSDocumentScripting only.pub fn handlePrintScriptCommand( &self, command: &NSScriptCommand, ) -> Option<Retained<AnyObject>>
NSDocumentScripting only.pub fn objectSpecifier(&self) -> Retained<NSScriptObjectSpecifier>
NSDocumentScripting only.pub fn userActivity(&self) -> Option<Retained<NSUserActivity>>
NSUserActivity only.Sourcepub fn setUserActivity(&self, user_activity: Option<&NSUserActivity>)
Available on crate feature NSUserActivity only.
pub fn setUserActivity(&self, user_activity: Option<&NSUserActivity>)
NSUserActivity only.Setter for userActivity.
pub fn updateUserActivityState(&self, activity: &NSUserActivity)
NSUserActivity only.Sourcepub 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.
pub unsafe fn restoreDocumentWindowWithIdentifier_state_completionHandler( &self, identifier: &NSUserInterfaceItemIdentifier, state: &NSCoder, completion_handler: &DynBlock<dyn Fn(*mut NSWindow, *mut NSError)>, )
NSWindowRestoration and NSResponder and NSUserInterfaceItemIdentification and NSWindow and block2 only.§Safety
state possibly has further requirements.
Sourcepub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder)
Available on crate feature NSWindowRestoration only.
pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder)
NSWindowRestoration only.§Safety
coder possibly has further requirements.
Sourcepub unsafe fn encodeRestorableStateWithCoder_backgroundQueue(
&self,
coder: &NSCoder,
queue: &NSOperationQueue,
)
Available on crate feature NSWindowRestoration only.
pub unsafe fn encodeRestorableStateWithCoder_backgroundQueue( &self, coder: &NSCoder, queue: &NSOperationQueue, )
NSWindowRestoration only.§Safety
coderpossibly has further requirements.queuepossibly has additional threading requirements.
Sourcepub unsafe fn restoreStateWithCoder(&self, coder: &NSCoder)
Available on crate feature NSWindowRestoration only.
pub unsafe fn restoreStateWithCoder(&self, coder: &NSCoder)
NSWindowRestoration only.§Safety
coder possibly has further requirements.
pub fn invalidateRestorableState(&self)
NSWindowRestoration only.Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
Available on crate feature NSAccessibilityConstants only.
pub fn class(&self) -> &'static AnyClass
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());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.Available on crate feature NSAccessibilityConstants only.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.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.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Available on crate feature NSAccessibilityConstants only.
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
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 NSPersistentDocument
impl AsRef<AnyObject> for NSPersistentDocument
Source§impl AsRef<NSDocument> for NSPersistentDocument
impl AsRef<NSDocument> for NSPersistentDocument
Source§fn as_ref(&self) -> &NSDocument
fn as_ref(&self) -> &NSDocument
Source§impl AsRef<NSObject> for NSPersistentDocument
impl AsRef<NSObject> for NSPersistentDocument
Source§impl Borrow<AnyObject> for NSPersistentDocument
impl Borrow<AnyObject> for NSPersistentDocument
Source§impl Borrow<NSDocument> for NSPersistentDocument
impl Borrow<NSDocument> for NSPersistentDocument
Source§fn borrow(&self) -> &NSDocument
fn borrow(&self) -> &NSDocument
Source§impl Borrow<NSObject> for NSPersistentDocument
impl Borrow<NSObject> for NSPersistentDocument
Source§impl ClassType for NSPersistentDocument
impl ClassType for NSPersistentDocument
Source§const NAME: &'static str = "NSPersistentDocument"
const NAME: &'static str = "NSPersistentDocument"
Source§type Super = NSDocument
type Super = NSDocument
Source§type ThreadKind = <<NSPersistentDocument as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<NSPersistentDocument as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for NSPersistentDocument
impl Debug for NSPersistentDocument
Source§impl Deref for NSPersistentDocument
impl Deref for NSPersistentDocument
Source§impl Hash for NSPersistentDocument
impl Hash for NSPersistentDocument
Source§impl Message for NSPersistentDocument
impl Message for NSPersistentDocument
Source§impl NSEditorRegistration for NSPersistentDocument
impl NSEditorRegistration for NSPersistentDocument
Source§fn objectDidBeginEditing(&self, editor: &ProtocolObject<dyn NSEditor>)
fn objectDidBeginEditing(&self, editor: &ProtocolObject<dyn NSEditor>)
NSKeyValueBinding only.Source§fn objectDidEndEditing(&self, editor: &ProtocolObject<dyn NSEditor>)
fn objectDidEndEditing(&self, editor: &ProtocolObject<dyn NSEditor>)
NSKeyValueBinding only.Source§impl NSFilePresenter for NSPersistentDocument
impl NSFilePresenter for NSPersistentDocument
fn presentedItemURL(&self) -> Option<Retained<NSURL>>
fn presentedItemOperationQueue(&self) -> Retained<NSOperationQueue>
fn primaryPresentedItemURL(&self) -> Option<Retained<NSURL>>
fn presentedItemDidMoveToURL(&self, new_url: &NSURL)
fn presentedItemDidChange(&self)
fn presentedItemDidChangeUbiquityAttributes(&self, attributes: &NSSet<NSString>)
fn observedPresentedItemUbiquityAttributes(&self) -> Retained<NSSet<NSString>>
fn presentedItemDidGainVersion(&self, version: &NSFileVersion)
fn presentedItemDidLoseVersion(&self, version: &NSFileVersion)
fn presentedItemDidResolveConflictVersion(&self, version: &NSFileVersion)
fn presentedSubitemDidAppearAtURL(&self, url: &NSURL)
fn presentedSubitemAtURL_didMoveToURL(&self, old_url: &NSURL, new_url: &NSURL)
fn presentedSubitemDidChangeAtURL(&self, url: &NSURL)
fn presentedSubitemAtURL_didGainVersion( &self, url: &NSURL, version: &NSFileVersion, )
fn presentedSubitemAtURL_didLoseVersion( &self, url: &NSURL, version: &NSFileVersion, )
fn presentedSubitemAtURL_didResolveConflictVersion( &self, url: &NSURL, version: &NSFileVersion, )
Source§impl NSMenuItemValidation for NSPersistentDocument
impl NSMenuItemValidation for NSPersistentDocument
Source§fn validateMenuItem(&self, menu_item: &NSMenuItem) -> bool
fn validateMenuItem(&self, menu_item: &NSMenuItem) -> bool
NSMenu and NSMenuItem only.Source§impl NSObjectProtocol for NSPersistentDocument
impl NSObjectProtocol for NSPersistentDocument
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_refSource§fn isMemberOfClass(&self, cls: &AnyClass) -> bool
fn isMemberOfClass(&self, cls: &AnyClass) -> bool
Source§fn respondsToSelector(&self, aSelector: Sel) -> bool
fn respondsToSelector(&self, aSelector: Sel) -> bool
Source§fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
Source§fn debugDescription(&self) -> Retained<NSObject>
fn debugDescription(&self) -> Retained<NSObject>
Source§impl NSUserInterfaceValidations for NSPersistentDocument
impl NSUserInterfaceValidations for NSPersistentDocument
Source§fn validateUserInterfaceItem(
&self,
item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>,
) -> bool
fn validateUserInterfaceItem( &self, item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>, ) -> bool
NSUserInterfaceValidation only.Source§impl PartialEq for NSPersistentDocument
impl PartialEq for NSPersistentDocument
Source§impl RefEncode for NSPersistentDocument
impl RefEncode for NSPersistentDocument
Source§const ENCODING_REF: Encoding = <NSDocument as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSDocument as ::objc2::RefEncode>::ENCODING_REF
impl DowncastTarget for NSPersistentDocument
impl Eq for NSPersistentDocument
Auto Trait Implementations§
impl !Freeze for NSPersistentDocument
impl !RefUnwindSafe for NSPersistentDocument
impl !Send for NSPersistentDocument
impl !Sync for NSPersistentDocument
impl !Unpin for NSPersistentDocument
impl !UnwindSafe for NSPersistentDocument
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<'a, T> MainThreadOnly for T
impl<'a, T> MainThreadOnly for T
Source§fn mtm(&self) -> MainThreadMarker
fn mtm(&self) -> MainThreadMarker
MainThreadMarker from the main-thread-only object. Read more