Struct NSDocument

Source
#[repr(C)]
pub struct NSDocument { /* private fields */ }
Available on crate feature NSDocument only.
Expand description

Implementations§

Source§

impl NSDocument

Source

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

Source

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

Source

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

Source

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

Source

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>>

Source

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

Source

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

Setter for fileType.

Source

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

Source

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

Setter for fileURL.

Source

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

Source

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

Source

pub unsafe fn isDraft(&self) -> bool

Source

pub unsafe fn setDraft(&self, draft: bool)

Setter for isDraft.

Source

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

Available on crate feature block2 only.
Source

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

Available on crate feature block2 only.
Source

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

Available on crate feature block2 only.
Source

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

Available on crate feature block2 only.
Source

pub unsafe 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>)

Source

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

Source

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

Source

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

Source

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

Source

pub unsafe fn isEntireFileLoaded(&self) -> bool

Source

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

Source

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

Source

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

Source

pub unsafe fn unblockUserInteraction(&self)

Source

pub unsafe fn autosavingIsImplicitlyCancellable(&self) -> bool

Source

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

Source

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>>

Source

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>>

Source

pub unsafe fn keepBackupFile(&self) -> bool

Source

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

Source

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

Source

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

Source

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

Source

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

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, )

Source

pub unsafe fn savePanelShowsFileFormatsControl(&self) -> bool

Source

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

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

pub unsafe fn fileNameExtensionWasHiddenInLastRunSavePanel(&self) -> bool

Source

pub unsafe 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, )

Source

pub unsafe 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 unsafe fn canAsynchronouslyWriteToURL_ofType_forSaveOperation( &self, url: &NSURL, type_name: &NSString, save_operation: NSSaveOperationType, ) -> bool

Source

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

Source

pub unsafe fn scheduleAutosaving(&self)

Source

pub unsafe 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, )

Source

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

Available on crate feature block2 only.
Source

pub unsafe fn autosavesInPlace(mtm: MainThreadMarker) -> bool

Source

pub unsafe fn preservesVersions(mtm: MainThreadMarker) -> bool

Source

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

Source

pub unsafe fn isBrowsingVersions(&self) -> bool

Source

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

Available on crate feature block2 only.
Source

pub unsafe fn autosavesDrafts(mtm: MainThreadMarker) -> bool

Source

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

Source

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

Source

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

Source

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

Source

pub unsafe fn close(&self)

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Available on crate feature block2 only.
Source

pub unsafe 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>)

Source

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

Source

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

Available on crate feature block2 only.
Source

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

Available on crate feature block2 only.
Source

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

Available on crate feature block2 only.
Source

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

Available on crate feature block2 only.
Source

pub unsafe fn isLocked(&self) -> bool

Source

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

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.
Source

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

Available on crate feature NSPageLayout only.
Source

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

Available on crate feature NSPrintInfo only.
Source

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

Available on crate feature NSPrintInfo only.
Source

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

Available on crate feature NSPrintInfo only.

Setter for printInfo.

Source

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

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.
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.
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.
Source

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

Source

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

Available on crate feature NSPrintOperation only.
Source

pub unsafe fn allowsDocumentSharing(&self) -> bool

Source

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

Available on crate features NSSharingService and block2 only.
Source

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

Available on crate feature NSSharingService only.
Source

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

Available on crate feature NSPreviewRepresentingActivityItem only.
Source

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

Available on crate feature NSPreviewRepresentingActivityItem only.
Source

pub unsafe fn isDocumentEdited(&self) -> bool

Source

pub unsafe fn isInViewingMode(&self) -> bool

Source

pub unsafe fn updateChangeCount(&self, change: NSDocumentChangeType)

Source

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

Source

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

Source

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

Source

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

Setter for undoManager.

Source

pub unsafe fn hasUndoManager(&self) -> bool

Source

pub unsafe 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.
Source

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

Source

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

Source

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

Source

pub unsafe fn makeWindowControllers(&self)

Source

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

Available on crate feature NSNib only.
Source

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

Available on crate features NSResponder and NSWindowController only.
Source

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

Available on crate features NSResponder and NSWindowController only.
Source

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

Available on crate features NSResponder and NSWindow only.
Source

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

Available on crate features NSResponder and NSWindowController only.
Source

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

Available on crate features NSResponder and NSWindowController only.
Source

pub unsafe fn showWindows(&self)

Source

pub unsafe 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.
Source

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

Source

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

Source

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

Available on crate features NSResponder and NSWindow only.
Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Available on crate feature NSUserInterfaceValidation only.
Source

pub unsafe fn usesUbiquitousStorage(mtm: MainThreadMarker) -> bool

Source

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

Source

pub unsafe 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.
Source

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

Available on crate feature block2 only.
Source

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

Available on crate feature block2 only.
Source

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

Available on crate feature block2 only.
Source

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

Source

pub unsafe fn presentedItemDidChange(&self)

Source

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

Source

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

Source

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

Source

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

Source§

impl NSDocument

Methods declared on superclass NSObject.

Source

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

Source§

impl NSDocument

NSDeprecated.

Source

pub unsafe fn shouldRunSavePanelWithAccessoryView(&self) -> bool

👎Deprecated
Source

pub unsafe 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 unsafe fn dataRepresentationOfType( &self, type: &NSString, ) -> Option<Retained<NSData>>

👎Deprecated
Source

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

👎Deprecated
Source

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

👎Deprecated
Source

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

👎Deprecated
Source

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

👎Deprecated
Source

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

👎Deprecated
Source

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

👎Deprecated
Source

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

👎Deprecated
Source

pub unsafe fn printShowingPrintPanel(&self, flag: bool)

👎Deprecated
Source

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

👎Deprecated
Source

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

👎Deprecated
Source

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

👎Deprecated
Source

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

👎Deprecated
Source

pub unsafe 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
Source

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

👎Deprecated
Source

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

👎Deprecated
Source

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

👎Deprecated
Source

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

👎Deprecated
Source

pub unsafe 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 unsafe fn lastComponentOfFileName(&self) -> Retained<NSString>

Available on crate feature NSDocumentScripting only.
Source

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

Available on crate feature NSDocumentScripting only.
Source

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

Available on crate feature NSDocumentScripting only.
Source

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

Available on crate feature NSDocumentScripting only.
Source

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

Available on crate feature NSDocumentScripting only.
Source

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

Available on crate feature NSDocumentScripting only.
Source§

impl NSDocument

NSUserActivity.

Source

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

Available on crate feature NSUserActivity only.
Source

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

Available on crate feature NSUserActivity only.

Setter for userActivity.

Source

pub unsafe 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.
Source

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

Available on crate feature NSWindowRestoration only.
Source

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

Available on crate feature NSWindowRestoration only.
Source

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

Available on crate feature NSWindowRestoration only.
Source

pub unsafe fn invalidateRestorableState(&self)

Available on crate feature NSWindowRestoration only.
Source

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

Available on crate feature NSWindowRestoration only.
Source

pub unsafe 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§

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

Available on crate feature NSKeyValueBinding only.
Source§

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

Available on crate feature NSKeyValueBinding only.
Source§

impl NSFilePresenter for NSDocument

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl NSMenuItemValidation for NSDocument

Source§

unsafe 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§

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

Source§

impl NSUserInterfaceValidations for NSDocument

Source§

unsafe 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,