I wonder if there’s a way to avoid a swiftc crash, because this would be deeply 
cool if it worked at all:

---
// Swift 1.2, Xcode 6.3.1, OS X
import Cocoa

class AppDelegate: NSObject, NSApplicationDelegate {
    @IBOutlet var textView: NSTextView!

    func somethingHappened(aParameter: Int) {
        // ...
        println("Something happened with code \(aParameter)",
                &textView)
        // ...
    }
}

extension NSTextView : OutputStreamType {
    public func write(string: String) {
        let attrString = NSAttributedString(string: string) as! NSTextStorage
        self.textStorage?.appendAttributedString(attrString)
    }
}
---

Unfortunately, swiftc and SourceServer crash. They _may_ be crashing because 
it’s a syntax error: The definition of OutputStreamType plainly contemplates a 
struct, and I’m nervous using a view outlet as an inout parameter, but the same 
thing happens when I try wrapping the view or .textStorage in a struct.

I can work around, but I am jonesing for my deeply cool println. Can anyone 
think of a way to make it work, or must I wait for my Radar to come through (if 
ever)?

[xcode-user because it’s an issue with a particular instance of the compiler, 
and not the language or Cocoa themselves.]

rdar://20685433

        — F


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to