Re: To Swiftly Crash
Re: To Swiftly Crash
- Subject: Re: To Swiftly Crash
- From: Quincey Morris <email@hidden>
- Date: Sun, 26 Apr 2015 20:04:59 +0000
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