Re: To Swiftly Crash
Re: To Swiftly Crash
- Subject: Re: To Swiftly Crash
- From: Charles Jenkins <email@hidden>
- Date: Mon, 27 Apr 2015 07:01:36 -0400
That’s it! Thank you, Quincey!
It no longer crashes if I put a question mark after replacementString:String and then ignore XCode’s warning, but I went ahead and implemented the “shouldChangeTextInRanges" method instead. Thanks for the quick, correct response!
--
Charles
On April 26, 2015 at 16:05:00, Quincey Morris (email@hidden) wrote:
On Apr 26, 2015, at 12:40 , Charles Jenkins <email@hidden> wrote:
Is this a disaster in Swift-to-ObjC bridging, or have I done something wrong to cause it?
func textView( tv:NSTextView, shouldChangeTextInRange range:NSRange, replacementString:String ) -> Bool
The problem is that the replacement string can be nil (if only attributes are being changed, which is what happens when you Command-B), but the bridged signature is missing a ‘?’ on the replacementString type. (You can see this if you change the type to ’String!’, ignore the warning, and see the log message when you run.) Why this is, I don’t know, but I doubt it’s your fault.
This delegate method is described as “superseded” in the header file. I suggest you try using the recommended method:
func textView(textView: NSTextView, shouldChangeTextInRanges affectedRanges: [AnyObject], replacementStrings: [AnyObject]?) -> Bool
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden