Re: [swift-users] So how do you implement a NSTextStorage subclass in Swift?

2017-02-13 Thread Michel Fortin via swift-users
Le 12 févr. 2017 à 18:41, Karl Wagner a écrit : > > I've seen this before; I considered it something to be resolved in AppKit. > Strings in Swift are values, and the framework expects it to be a reference. > Since NSTextStorage is itself a reference-type and informs its

Re: [swift-users] So how do you implement a NSTextStorage subclass in Swift?

2017-02-12 Thread Karl Wagner via swift-users
I've seen this before; I considered it something to be resolved in AppKit. Strings in Swift are values, and the framework expects it to be a reference. Since NSTextStorage is itself a reference-type and informs its delegate of changes, those frameworks should probably retain the NSTS

Re: [swift-users] So how do you implement a NSTextStorage subclass in Swift?

2017-02-10 Thread Jacob Bandes-Storch via swift-users
Got some clarity on this from Apple folks on Twitter: https://twitter.com/jtbandes/status/830159670559993856 On Fri, Feb 10, 2017 at 12:54 PM, Michel Fortin wrote: > I did file one (30314719). I might not have explained the problem clearly > enough, I suppose, because

Re: [swift-users] So how do you implement a NSTextStorage subclass in Swift?

2017-02-10 Thread Jacob Bandes-Storch via swift-users
This seems like a bug (missing feature?) in how the API is imported for Swift. You might consider filing a Radar. On Thu, Feb 9, 2017 at 3:12 PM Michel Fortin via swift-users < swift-users@swift.org> wrote: > The `string` property of `NSTextStorage` is of type `String`, but the > contract it

Re: [swift-users] So how do you implement a NSTextStorage subclass in Swift?

2017-02-10 Thread Michel Fortin via swift-users
In case this is useful to someone, this is the workaround I'll be using: ``` class CustomTextStorage: NSTextStorage { private let backingStore: NSMutableAttributedString // This method should never get called from Objective-C as it doesn't respect // the API contract

[swift-users] So how do you implement a NSTextStorage subclass in Swift?

2017-02-09 Thread Michel Fortin via swift-users
The `string` property of `NSTextStorage` is of type `String`, but the contract it must implement is that it should return the backing store of the attributed string (the underlying `NSMutableString` used as the backing store). It seems to me that this makes it impossible to implement correctly