logo
down
shadow

How do I initialise a new NSDocument instance in Swift?


How do I initialise a new NSDocument instance in Swift?

By : Maurice Périard
Date : November 17 2020, 04:28 AM
will help you Apple documentation suggests to override an NSDocument convenience init (initWithType:error:) as described here. , To execute init code for a new document:
code :
// Create new document (only called for new documents)
convenience init?(type typeName: String, error outError: NSErrorPointer) {
    self.init()
    fileType = typeName
    // add your own initialisation for new document here
}


Share : facebook icon twitter icon
Closing specific NSDocument instance with notifications

Closing specific NSDocument instance with notifications


By : user3269575
Date : March 29 2020, 07:55 AM
this one helps. You could also call an action method when the cancel button is pressed. This way the action method manages to close the sheet and close your NSDocument subclass instance.
NSDocument subclass instance apparently not in responder chain

NSDocument subclass instance apparently not in responder chain


By : themba hlathini
Date : March 29 2020, 07:55 AM
it fixes the issue I'm going to suggest that the solution is the one pointed to here:
https://stackoverflow.com/a/9349636/341994
How to create a new instance of an NSDocument with NSDocumentController?

How to create a new instance of an NSDocument with NSDocumentController?


By : MJaramillo
Date : March 29 2020, 07:55 AM
To fix the issue you can do I tried , Did you try like this below:-
code :
   [[NSDocumentController sharedDocumentController]newDocument:self];
How can you implement the NSDocument method -canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo: in Swift?

How can you implement the NSDocument method -canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo: in Swift?


By : Iiver fc pool
Date : March 29 2020, 07:55 AM
I hope this helps . In my application, a NSDocument subclass mission-critical hardware – users really don’t want to close a document by accident! So, I’ve implemented canCloseDocumentWithDelegate… to show an NSAlert and ask before closing. , You can solve this with some low level runtime functions:
code :
override func canCloseDocumentWithDelegate(delegate: AnyObject, shouldCloseSelector: Selector, contextInfo: UnsafeMutablePointer<Void>) {

    let allowed = true // ...or false. Add your logic here.

    let Class: AnyClass = object_getClass(delegate)
    let method = class_getMethodImplementation(Class, shouldCloseSelector)

    typealias signature = @convention(c) (AnyObject, Selector, AnyObject, Bool, UnsafeMutablePointer<Void>) -> Void
    let function = unsafeBitCast(method, signature.self)

    function(delegate, shouldCloseSelector, self, allowed, contextInfo)
}
`attemptRecovery(fromError:optionIndex:)` not found on super of Swift subclass of NSDocument

`attemptRecovery(fromError:optionIndex:)` not found on super of Swift subclass of NSDocument


By : leymirable
Date : March 29 2020, 07:55 AM
will be helpful for those in need attemptRecoveryFromError:optionIndex: is a method of informal protocol NSErrorRecoveryAttempting and is not implemented by NSObject See Formal and Informal Protocols
Related Posts Related Posts :
  • consecutive statement need to have ; error in swift
  • Trying to create a 32 bpc NSBitmapImageRep, getting hit with errors
  • Does locationManager:didUpdateLocations: method called at the same time in extension and its containing app
  • Can't get Data using SwiftyJSON
  • Convert String to UnsafeMutablePointer<char_t> in Swift
  • inout param with empty object since nil won't work
  • How to align a mask onto an image
  • compiler forcing self inside static method of a function while using dispatch_sync
  • private static variable in struct
  • Conditional "in" for arrays in Swift
  • Extension for Double to accept String as initializer in Swift
  • Modifying UIButton Programmatically
  • Pass type to generic function and compare
  • How to customise the look of the PFSignUpViewController
  • How to take screen shot programmatically (Swift, SpriteKit)
  • Setting NavigationController's NavigationBar translucent property to false causes extra padding
  • Create multiple UIViews when the user taps the screen
  • Filter Array of [AnyObject] in Swift
  • How to add ParseUI to a swift project
  • Can Swift enums have multiple raw values?
  • Using a function() variable in a different Class - Swift
  • Masking an image in Swift using CALayer and UIImage
  • KVC without NSObject (NSPredicate)
  • Any? to Dictionary Cast and retrieving value
  • NSCharacterSet.characterIsMember() with Swift's Character type
  • SCNScene: Calculate projected size of an object
  • How to use contains on a swiftyJSON object
  • Index of element in sorted()
  • Multiple functions with the same name
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org