#[repr(C)]pub struct NSDocument { /* private fields */ }
NSDocument
only.Expand description
Implementations§
Source§impl NSDocument
impl NSDocument
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
pub unsafe fn initWithType_error( this: Allocated<Self>, type_name: &NSString, ) -> Result<Retained<Self>, Retained<NSError>>
pub unsafe fn canConcurrentlyReadDocumentsOfType( type_name: &NSString, mtm: MainThreadMarker, ) -> bool
pub unsafe fn initWithContentsOfURL_ofType_error( this: Allocated<Self>, url: &NSURL, type_name: &NSString, ) -> Result<Retained<Self>, Retained<NSError>>
pub unsafe fn initForURL_withContentsOfURL_ofType_error( this: Allocated<Self>, url_or_nil: Option<&NSURL>, contents_url: &NSURL, type_name: &NSString, ) -> Result<Retained<Self>, Retained<NSError>>
pub unsafe fn fileType(&self) -> Option<Retained<NSString>>
Sourcepub unsafe fn setFileType(&self, file_type: Option<&NSString>)
pub unsafe fn setFileType(&self, file_type: Option<&NSString>)
Setter for fileType
.
pub unsafe fn fileURL(&self) -> Option<Retained<NSURL>>
Sourcepub unsafe fn setFileURL(&self, file_url: Option<&NSURL>)
pub unsafe fn setFileURL(&self, file_url: Option<&NSURL>)
Setter for fileURL
.
pub unsafe fn fileModificationDate(&self) -> Option<Retained<NSDate>>
Sourcepub unsafe fn setFileModificationDate(
&self,
file_modification_date: Option<&NSDate>,
)
pub unsafe fn setFileModificationDate( &self, file_modification_date: Option<&NSDate>, )
Setter for fileModificationDate
.
pub unsafe fn isDraft(&self) -> bool
pub unsafe fn performActivityWithSynchronousWaiting_usingBlock( &self, wait_synchronously: bool, block: &DynBlock<dyn Fn(NonNull<DynBlock<dyn Fn()>>)>, )
block2
only.pub unsafe fn continueActivityUsingBlock(&self, block: &DynBlock<dyn Fn() + '_>)
block2
only.pub unsafe fn continueAsynchronousWorkOnMainThreadUsingBlock( &self, block: &DynBlock<dyn Fn()>, )
block2
only.pub unsafe fn performSynchronousFileAccessUsingBlock( &self, block: &DynBlock<dyn Fn() + '_>, )
block2
only.pub unsafe fn performAsynchronousFileAccessUsingBlock( &self, block: &DynBlock<dyn Fn(NonNull<DynBlock<dyn Fn()>>)>, )
block2
only.pub unsafe fn revertDocumentToSaved(&self, sender: Option<&AnyObject>)
pub unsafe fn revertToContentsOfURL_ofType_error( &self, url: &NSURL, type_name: &NSString, ) -> Result<(), Retained<NSError>>
pub unsafe fn readFromURL_ofType_error( &self, url: &NSURL, type_name: &NSString, ) -> Result<(), Retained<NSError>>
pub unsafe fn readFromFileWrapper_ofType_error( &self, file_wrapper: &NSFileWrapper, type_name: &NSString, ) -> Result<(), Retained<NSError>>
pub unsafe fn readFromData_ofType_error( &self, data: &NSData, type_name: &NSString, ) -> Result<(), Retained<NSError>>
pub unsafe fn isEntireFileLoaded(&self) -> bool
pub unsafe fn writeToURL_ofType_error( &self, url: &NSURL, type_name: &NSString, ) -> Result<(), Retained<NSError>>
pub unsafe fn fileWrapperOfType_error( &self, type_name: &NSString, ) -> Result<Retained<NSFileWrapper>, Retained<NSError>>
pub unsafe fn dataOfType_error( &self, type_name: &NSString, ) -> Result<Retained<NSData>, Retained<NSError>>
pub unsafe fn unblockUserInteraction(&self)
pub unsafe fn autosavingIsImplicitlyCancellable(&self) -> bool
pub unsafe fn writeSafelyToURL_ofType_forSaveOperation_error( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, ) -> Result<(), Retained<NSError>>
pub unsafe 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 unsafe 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 unsafe fn keepBackupFile(&self) -> bool
pub unsafe fn backupFileURL(&self) -> Option<Retained<NSURL>>
pub unsafe fn saveDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn saveDocumentAs(&self, sender: Option<&AnyObject>)
pub unsafe fn saveDocumentTo(&self, sender: Option<&AnyObject>)
pub unsafe fn saveDocumentWithDelegate_didSaveSelector_contextInfo( &self, 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, )
pub unsafe fn savePanelShowsFileFormatsControl(&self) -> bool
pub unsafe fn prepareSavePanel(&self, save_panel: &NSSavePanel) -> bool
NSPanel
and NSResponder
and NSSavePanel
and NSWindow
only.pub unsafe fn fileNameExtensionWasHiddenInLastRunSavePanel(&self) -> bool
pub unsafe fn fileTypeFromLastRunSavePanel(&self) -> Option<Retained<NSString>>
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, )
pub unsafe fn saveToURL_ofType_forSaveOperation_completionHandler( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )
block2
only.pub unsafe fn canAsynchronouslyWriteToURL_ofType_forSaveOperation( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, ) -> bool
pub unsafe fn checkAutosavingSafetyAndReturnError( &self, ) -> Result<(), Retained<NSError>>
pub unsafe fn scheduleAutosaving(&self)
pub unsafe fn hasUnautosavedChanges(&self) -> bool
pub unsafe fn autosaveDocumentWithDelegate_didAutosaveSelector_contextInfo( &self, delegate: Option<&AnyObject>, did_autosave_selector: Option<Sel>, context_info: *mut c_void, )
pub unsafe fn autosaveWithImplicitCancellability_completionHandler( &self, autosaving_is_implicitly_cancellable: bool, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )
block2
only.pub unsafe fn autosavesInPlace(mtm: MainThreadMarker) -> bool
pub unsafe fn preservesVersions(mtm: MainThreadMarker) -> bool
pub unsafe fn browseDocumentVersions(&self, sender: Option<&AnyObject>)
pub unsafe fn isBrowsingVersions(&self) -> bool
pub unsafe fn stopBrowsingVersionsWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn()>>, )
block2
only.pub unsafe fn autosavesDrafts(mtm: MainThreadMarker) -> bool
pub unsafe fn autosavingFileType(&self) -> Option<Retained<NSString>>
pub unsafe fn autosavedContentsFileURL(&self) -> Option<Retained<NSURL>>
Sourcepub unsafe fn setAutosavedContentsFileURL(
&self,
autosaved_contents_file_url: Option<&NSURL>,
)
pub unsafe fn setAutosavedContentsFileURL( &self, autosaved_contents_file_url: Option<&NSURL>, )
Setter for autosavedContentsFileURL
.
pub unsafe fn canCloseDocumentWithDelegate_shouldCloseSelector_contextInfo( &self, delegate: &AnyObject, should_close_selector: Option<Sel>, context_info: *mut c_void, )
pub unsafe fn close(&self)
pub unsafe fn duplicateDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn duplicateDocumentWithDelegate_didDuplicateSelector_contextInfo( &self, delegate: Option<&AnyObject>, did_duplicate_selector: Option<Sel>, context_info: *mut c_void, )
pub unsafe fn duplicateAndReturnError( &self, ) -> Result<Retained<NSDocument>, Retained<NSError>>
pub unsafe fn renameDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn moveDocumentToUbiquityContainer(&self, sender: Option<&AnyObject>)
pub unsafe fn moveDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn moveDocumentWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(Bool)>>, )
block2
only.pub unsafe fn moveToURL_completionHandler( &self, url: &NSURL, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )
block2
only.pub unsafe fn lockDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn unlockDocument(&self, sender: Option<&AnyObject>)
pub unsafe fn lockDocumentWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(Bool)>>, )
block2
only.pub unsafe fn lockWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )
block2
only.pub unsafe fn unlockDocumentWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(Bool)>>, )
block2
only.pub unsafe fn unlockWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )
block2
only.pub unsafe fn isLocked(&self) -> bool
pub unsafe fn runPageLayout(&self, sender: Option<&AnyObject>)
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.pub unsafe fn preparePageLayout(&self, page_layout: &NSPageLayout) -> bool
NSPageLayout
only.pub unsafe fn shouldChangePrintInfo(&self, new_print_info: &NSPrintInfo) -> bool
NSPrintInfo
only.pub unsafe fn printInfo(&self) -> Retained<NSPrintInfo>
NSPrintInfo
only.Sourcepub unsafe fn setPrintInfo(&self, print_info: &NSPrintInfo)
Available on crate feature NSPrintInfo
only.
pub unsafe fn setPrintInfo(&self, print_info: &NSPrintInfo)
NSPrintInfo
only.Setter for printInfo
.
pub unsafe fn printDocument(&self, sender: Option<&AnyObject>)
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.pub unsafe fn printOperationWithSettings_error( &self, print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>, ) -> Result<Retained<NSPrintOperation>, Retained<NSError>>
NSPrintInfo
and 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.pub unsafe fn saveDocumentToPDF(&self, sender: Option<&AnyObject>)
pub unsafe fn PDFPrintOperation(&self) -> Retained<NSPrintOperation>
NSPrintOperation
only.pub unsafe fn allowsDocumentSharing(&self) -> bool
NSSharingService
and block2
only.pub unsafe fn prepareSharingServicePicker( &self, sharing_service_picker: &NSSharingServicePicker, )
NSSharingService
only.pub unsafe fn previewRepresentableActivityItems( &self, ) -> Option<Retained<NSArray<ProtocolObject<dyn NSPreviewRepresentableActivityItem>>>>
NSPreviewRepresentingActivityItem
only.Sourcepub unsafe fn setPreviewRepresentableActivityItems(
&self,
preview_representable_activity_items: Option<&NSArray<ProtocolObject<dyn NSPreviewRepresentableActivityItem>>>,
)
Available on crate feature NSPreviewRepresentingActivityItem
only.
pub unsafe fn setPreviewRepresentableActivityItems( &self, preview_representable_activity_items: Option<&NSArray<ProtocolObject<dyn NSPreviewRepresentableActivityItem>>>, )
NSPreviewRepresentingActivityItem
only.Setter for previewRepresentableActivityItems
.
pub unsafe fn isDocumentEdited(&self) -> bool
pub unsafe fn isInViewingMode(&self) -> bool
pub unsafe fn updateChangeCount(&self, change: NSDocumentChangeType)
pub unsafe fn changeCountTokenForSaveOperation( &self, save_operation: NSSaveOperationType, ) -> Retained<AnyObject>
pub unsafe fn updateChangeCountWithToken_forSaveOperation( &self, change_count_token: &AnyObject, save_operation: NSSaveOperationType, )
pub unsafe fn undoManager(&self) -> Option<Retained<NSUndoManager>>
Sourcepub unsafe fn setUndoManager(&self, undo_manager: Option<&NSUndoManager>)
pub unsafe fn setUndoManager(&self, undo_manager: Option<&NSUndoManager>)
Setter for undoManager
.
pub unsafe fn hasUndoManager(&self) -> bool
Sourcepub unsafe fn setHasUndoManager(&self, has_undo_manager: bool)
pub unsafe fn setHasUndoManager(&self, has_undo_manager: bool)
Setter for hasUndoManager
.
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.pub unsafe fn presentError(&self, error: &NSError) -> bool
pub unsafe fn willPresentError(&self, error: &NSError) -> Retained<NSError>
pub unsafe fn willNotPresentError(&self, error: &NSError)
pub unsafe fn makeWindowControllers(&self)
pub unsafe fn windowNibName(&self) -> Option<Retained<NSNibName>>
NSNib
only.pub unsafe fn windowControllerWillLoadNib( &self, window_controller: &NSWindowController, )
NSResponder
and NSWindowController
only.pub unsafe fn windowControllerDidLoadNib( &self, window_controller: &NSWindowController, )
NSResponder
and NSWindowController
only.pub unsafe fn setWindow(&self, window: Option<&NSWindow>)
NSResponder
and NSWindow
only.pub unsafe fn addWindowController(&self, window_controller: &NSWindowController)
NSResponder
and NSWindowController
only.pub unsafe fn removeWindowController( &self, window_controller: &NSWindowController, )
NSResponder
and NSWindowController
only.pub unsafe fn showWindows(&self)
pub unsafe fn windowControllers(&self) -> Retained<NSArray<NSWindowController>>
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.pub unsafe fn displayName(&self) -> Retained<NSString>
pub unsafe fn defaultDraftName(&self) -> Retained<NSString>
pub unsafe fn windowForSheet(&self) -> Option<Retained<NSWindow>>
NSResponder
and NSWindow
only.pub unsafe fn readableTypes( mtm: MainThreadMarker, ) -> Retained<NSArray<NSString>>
pub unsafe fn writableTypes( mtm: MainThreadMarker, ) -> Retained<NSArray<NSString>>
pub unsafe fn isNativeType(type: &NSString, mtm: MainThreadMarker) -> bool
pub unsafe fn writableTypesForSaveOperation( &self, save_operation: NSSaveOperationType, ) -> Retained<NSArray<NSString>>
pub unsafe fn fileNameExtensionForType_saveOperation( &self, type_name: &NSString, save_operation: NSSaveOperationType, ) -> Option<Retained<NSString>>
pub unsafe fn validateUserInterfaceItem( &self, item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>, ) -> bool
NSUserInterfaceValidation
only.pub unsafe fn usesUbiquitousStorage(mtm: MainThreadMarker) -> bool
pub unsafe fn presentedItemURL(&self) -> Option<Retained<NSURL>>
pub unsafe fn observedPresentedItemUbiquityAttributes( &self, ) -> Retained<NSSet<NSURLResourceKey>>
pub unsafe fn relinquishPresentedItemToReader( &self, reader: &DynBlock<dyn Fn(*mut DynBlock<dyn Fn()>)>, )
block2
only.pub unsafe fn relinquishPresentedItemToWriter( &self, writer: &DynBlock<dyn Fn(*mut DynBlock<dyn Fn()>)>, )
block2
only.pub unsafe fn savePresentedItemChangesWithCompletionHandler( &self, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )
block2
only.pub unsafe fn accommodatePresentedItemDeletionWithCompletionHandler( &self, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )
block2
only.pub unsafe fn presentedItemDidMoveToURL(&self, new_url: &NSURL)
pub unsafe fn presentedItemDidChange(&self)
pub unsafe fn presentedItemDidChangeUbiquityAttributes( &self, attributes: &NSSet<NSURLResourceKey>, )
pub unsafe fn presentedItemDidGainVersion(&self, version: &NSFileVersion)
pub unsafe fn presentedItemDidLoseVersion(&self, version: &NSFileVersion)
pub unsafe fn presentedItemDidResolveConflictVersion( &self, version: &NSFileVersion, )
Source§impl NSDocument
Methods declared on superclass NSObject
.
impl NSDocument
Methods declared on superclass NSObject
.
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>
Source§impl NSDocument
NSDeprecated.
impl NSDocument
NSDeprecated.
pub unsafe fn shouldRunSavePanelWithAccessoryView(&self) -> bool
pub unsafe fn saveToURL_ofType_forSaveOperation_error( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, ) -> Result<(), Retained<NSError>>
pub unsafe fn dataRepresentationOfType( &self, type: &NSString, ) -> Option<Retained<NSData>>
pub unsafe fn fileAttributesToWriteToFile_ofType_saveOperation( &self, full_document_path: &NSString, document_type_name: &NSString, save_operation_type: NSSaveOperationType, ) -> Option<Retained<NSDictionary>>
pub unsafe fn fileName(&self) -> Option<Retained<NSString>>
pub unsafe fn fileWrapperRepresentationOfType( &self, type: &NSString, ) -> Option<Retained<NSFileWrapper>>
pub unsafe fn initWithContentsOfFile_ofType( this: Allocated<Self>, absolute_path: &NSString, type_name: &NSString, ) -> Option<Retained<Self>>
pub unsafe fn initWithContentsOfURL_ofType( this: Allocated<Self>, url: &NSURL, type_name: &NSString, ) -> Option<Retained<Self>>
pub unsafe fn loadDataRepresentation_ofType( &self, data: &NSData, type: &NSString, ) -> bool
pub unsafe fn loadFileWrapperRepresentation_ofType( &self, wrapper: &NSFileWrapper, type: &NSString, ) -> bool
pub unsafe fn printShowingPrintPanel(&self, flag: bool)
pub unsafe fn readFromFile_ofType( &self, file_name: &NSString, type: &NSString, ) -> bool
pub unsafe fn readFromURL_ofType(&self, url: &NSURL, type: &NSString) -> bool
pub unsafe fn revertToSavedFromFile_ofType( &self, file_name: &NSString, type: &NSString, ) -> bool
pub unsafe fn revertToSavedFromURL_ofType( &self, url: &NSURL, type: &NSString, ) -> bool
pub unsafe fn runModalPageLayoutWithPrintInfo( &self, print_info: &NSPrintInfo, ) -> NSInteger
NSPrintInfo
only.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, )
pub unsafe fn setFileName(&self, file_name: Option<&NSString>)
pub unsafe fn writeToFile_ofType( &self, file_name: &NSString, type: &NSString, ) -> bool
pub unsafe 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 unsafe fn writeToURL_ofType(&self, url: &NSURL, type: &NSString) -> bool
pub unsafe fn writeWithBackupToFile_ofType_saveOperation( &self, full_document_path: &NSString, document_type_name: &NSString, save_operation_type: NSSaveOperationType, ) -> bool
Source§impl NSDocument
NSScripting.
impl NSDocument
NSScripting.
pub unsafe fn lastComponentOfFileName(&self) -> Retained<NSString>
NSDocumentScripting
only.Sourcepub unsafe fn setLastComponentOfFileName(
&self,
last_component_of_file_name: &NSString,
)
Available on crate feature NSDocumentScripting
only.
pub unsafe fn setLastComponentOfFileName( &self, last_component_of_file_name: &NSString, )
NSDocumentScripting
only.Setter for lastComponentOfFileName
.
pub unsafe fn handleSaveScriptCommand( &self, command: &NSScriptCommand, ) -> Option<Retained<AnyObject>>
NSDocumentScripting
only.pub unsafe fn handleCloseScriptCommand( &self, command: &NSCloseCommand, ) -> Option<Retained<AnyObject>>
NSDocumentScripting
only.pub unsafe fn handlePrintScriptCommand( &self, command: &NSScriptCommand, ) -> Option<Retained<AnyObject>>
NSDocumentScripting
only.pub unsafe fn objectSpecifier(&self) -> Retained<NSScriptObjectSpecifier>
NSDocumentScripting
only.Source§impl NSDocument
NSUserActivity.
impl NSDocument
NSUserActivity.
pub unsafe fn userActivity(&self) -> Option<Retained<NSUserActivity>>
NSUserActivity
only.Sourcepub unsafe fn setUserActivity(&self, user_activity: Option<&NSUserActivity>)
Available on crate feature NSUserActivity
only.
pub unsafe fn setUserActivity(&self, user_activity: Option<&NSUserActivity>)
NSUserActivity
only.Setter for userActivity
.
pub unsafe fn updateUserActivityState(&self, activity: &NSUserActivity)
NSUserActivity
only.Source§impl NSDocument
NSRestorableState.
impl NSDocument
NSRestorableState.
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.pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder)
NSWindowRestoration
only.pub unsafe fn encodeRestorableStateWithCoder_backgroundQueue( &self, coder: &NSCoder, queue: &NSOperationQueue, )
NSWindowRestoration
only.pub unsafe fn restoreStateWithCoder(&self, coder: &NSCoder)
NSWindowRestoration
only.pub unsafe fn invalidateRestorableState(&self)
NSWindowRestoration
only.pub unsafe fn restorableStateKeyPaths( mtm: MainThreadMarker, ) -> Retained<NSArray<NSString>>
NSWindowRestoration
only.pub unsafe fn allowedClassesForRestorableStateKeyPath( key_path: &NSString, mtm: MainThreadMarker, ) -> Retained<NSArray<AnyClass>>
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 NSDocument
impl AsRef<AnyObject> for NSDocument
Source§impl AsRef<NSDocument> for NSDocument
impl AsRef<NSDocument> for NSDocument
Source§impl AsRef<NSDocument> for NSPersistentDocument
Available on crate feature NSPersistentDocument
only.
impl AsRef<NSDocument> for NSPersistentDocument
NSPersistentDocument
only.Source§fn as_ref(&self) -> &NSDocument
fn as_ref(&self) -> &NSDocument
Source§impl AsRef<NSObject> for NSDocument
impl AsRef<NSObject> for NSDocument
Source§impl Borrow<AnyObject> for NSDocument
impl Borrow<AnyObject> for NSDocument
Source§impl Borrow<NSDocument> for NSPersistentDocument
Available on crate feature NSPersistentDocument
only.
impl Borrow<NSDocument> for NSPersistentDocument
NSPersistentDocument
only.Source§fn borrow(&self) -> &NSDocument
fn borrow(&self) -> &NSDocument
Source§impl Borrow<NSObject> for NSDocument
impl Borrow<NSObject> for NSDocument
Source§impl ClassType for NSDocument
impl ClassType for NSDocument
Source§const NAME: &'static str = "NSDocument"
const NAME: &'static str = "NSDocument"
Source§type ThreadKind = dyn MainThreadOnly
type ThreadKind = dyn MainThreadOnly
Source§impl Debug for NSDocument
impl Debug for NSDocument
Source§impl Deref for NSDocument
impl Deref for NSDocument
Source§impl Hash for NSDocument
impl Hash for NSDocument
Source§impl Message for NSDocument
impl Message for NSDocument
Source§impl NSEditorRegistration for NSDocument
impl NSEditorRegistration for NSDocument
Source§unsafe fn objectDidBeginEditing(&self, editor: &ProtocolObject<dyn NSEditor>)
unsafe fn objectDidBeginEditing(&self, editor: &ProtocolObject<dyn NSEditor>)
NSKeyValueBinding
only.Source§unsafe fn objectDidEndEditing(&self, editor: &ProtocolObject<dyn NSEditor>)
unsafe fn objectDidEndEditing(&self, editor: &ProtocolObject<dyn NSEditor>)
NSKeyValueBinding
only.Source§impl NSFilePresenter for NSDocument
impl NSFilePresenter for NSDocument
unsafe fn presentedItemURL(&self) -> Option<Retained<NSURL>>
unsafe fn presentedItemOperationQueue(&self) -> Retained<NSOperationQueue>
unsafe fn primaryPresentedItemURL(&self) -> Option<Retained<NSURL>>
unsafe fn presentedItemDidMoveToURL(&self, new_url: &NSURL)
unsafe fn presentedItemDidChange(&self)
unsafe fn presentedItemDidChangeUbiquityAttributes( &self, attributes: &NSSet<NSString>, )
unsafe fn observedPresentedItemUbiquityAttributes( &self, ) -> Retained<NSSet<NSString>>
unsafe fn presentedItemDidGainVersion(&self, version: &NSFileVersion)
unsafe fn presentedItemDidLoseVersion(&self, version: &NSFileVersion)
unsafe fn presentedItemDidResolveConflictVersion(&self, version: &NSFileVersion)
unsafe fn presentedSubitemDidAppearAtURL(&self, url: &NSURL)
unsafe fn presentedSubitemAtURL_didMoveToURL( &self, old_url: &NSURL, new_url: &NSURL, )
unsafe fn presentedSubitemDidChangeAtURL(&self, url: &NSURL)
unsafe fn presentedSubitemAtURL_didGainVersion( &self, url: &NSURL, version: &NSFileVersion, )
unsafe fn presentedSubitemAtURL_didLoseVersion( &self, url: &NSURL, version: &NSFileVersion, )
unsafe fn presentedSubitemAtURL_didResolveConflictVersion( &self, url: &NSURL, version: &NSFileVersion, )
Source§impl NSMenuItemValidation for NSDocument
impl NSMenuItemValidation for NSDocument
Source§unsafe fn validateMenuItem(&self, menu_item: &NSMenuItem) -> bool
unsafe fn validateMenuItem(&self, menu_item: &NSMenuItem) -> bool
NSMenu
and NSMenuItem
only.Source§impl NSObjectProtocol for NSDocument
impl NSObjectProtocol for NSDocument
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_ref
Source§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 NSUserActivityRestoring for NSDocument
Available on crate feature NSUserActivity
only.
impl NSUserActivityRestoring for NSDocument
NSUserActivity
only.unsafe fn restoreUserActivityState(&self, user_activity: &NSUserActivity)
Source§impl NSUserInterfaceValidations for NSDocument
impl NSUserInterfaceValidations for NSDocument
Source§unsafe fn validateUserInterfaceItem(
&self,
item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>,
) -> bool
unsafe fn validateUserInterfaceItem( &self, item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>, ) -> bool
NSUserInterfaceValidation
only.Source§impl PartialEq for NSDocument
impl PartialEq for NSDocument
Source§impl RefEncode for NSDocument
impl RefEncode for NSDocument
Source§const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
impl DowncastTarget for NSDocument
impl Eq for NSDocument
Auto Trait Implementations§
impl !Freeze for NSDocument
impl !RefUnwindSafe for NSDocument
impl !Send for NSDocument
impl !Sync for NSDocument
impl !Unpin for NSDocument
impl !UnwindSafe for NSDocument
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