swift-playground

How to use frameworks imported with carthage in swift playground

流过昼夜 提交于 2019-12-03 02:09:21
i have a swift project with some frameworks added via carthage. Is it possible to use those frameworks in playground inside project and how to use it, because import Argo doesn't work :( This stopped working at some point. Sigh What I do now is Create a macOS > Command Line Tool. Create a Cartfile with github "ReactiveX/RxSwift" and run carthage update --platform iOS Go to the command line tool target and add the frameworks from Carthage/Build/iOS in Linked frameworks and Libraries Add the playground files. At this point I’m able to run the playground files. 🤷🏻‍♂️ A playground has access to

Get playground to display all loop results

回眸只為那壹抹淺笑 提交于 2019-12-02 22:34:20
I'm using an xcode 7 playground, and I want to know how to make the playground display all the results printed out by a loop. for example: This will tell me the loop ran 4 times, but it will only display the last value of the iteration. Is there a way I can make it show all values? Right click on the inline quick look (the gray rounded rectangle with "4" in it). There's an option to show all the results in a list: You can also show everything that's been printed to the console for the entire playground execution by clicking the show debug area button all the way in the bottom left corner: In

MacOS Playground: How can change the background color?

天涯浪子 提交于 2019-12-02 15:28:54
问题 I'm trying to change the background color of main view: import AppKit import PlaygroundSupport class ViewController : NSViewController { override func loadView() { let nibFile = NSNib.Name("MyView") var topLevelObjects : NSArray? Bundle.main.loadNibNamed( nibFile, owner:nil, topLevelObjects: &topLevelObjects) let views = (topLevelObjects as! Array<Any>).filter { $0 is NSView } self.view = views[0] as! NSView self.view.layer?.backgroundColor = NSColor.white.cgColor } } PlaygroundPage.current

MacOS Playground: How can change the background color?

僤鯓⒐⒋嵵緔 提交于 2019-12-02 11:32:59
I'm trying to change the background color of main view: import AppKit import PlaygroundSupport class ViewController : NSViewController { override func loadView() { let nibFile = NSNib.Name("MyView") var topLevelObjects : NSArray? Bundle.main.loadNibNamed( nibFile, owner:nil, topLevelObjects: &topLevelObjects) let views = (topLevelObjects as! Array<Any>).filter { $0 is NSView } self.view = views[0] as! NSView self.view.layer?.backgroundColor = NSColor.white.cgColor } } PlaygroundPage.current.liveView = ViewController() But the view doesn't change the color: Also where the "Hello world" label is

Declaring conformance to @objc protocol in empty extension breaks with EXC_BAD_INSTRUCTION

孤街醉人 提交于 2019-12-02 11:26:21
问题 Been having lots and lots of trouble with Swift protocols in combination with arrays, but I couldn't even reproduce my whole problem before things started to break in playground. Here's a minimal example. I have two protocols and a class Bus which declares conformance to one of the protocols. In addition, an empty extension of Bus declares conformance to the other protocol: import Foundation @objc protocol Displayable { var name: String {get} } @objc protocol Utterable { var utterance: String

DispatchWorkItem not notifying main thread

ぐ巨炮叔叔 提交于 2019-12-02 11:14:09
Note: This is not duplicate question I have already seen Dispatch group - cannot notify to main thread There is nothing answered about DispatchWorkItem I have code like below let dwi3 = DispatchWorkItem { print("start DispatchWorkItem \(Thread.isMainThread)") sleep(2) print("end DispatchWorkItem") } let myDq = DispatchQueue(label: "A custom dispatch queue") dwi3.notify(queue: myDq) { print("notify") } DispatchQueue.global().async(execute: dwi3) Which is working correctly (I can see notify on console) and not in main thread start DispatchWorkItem false start DispatchWorkItem false end

Declaring conformance to @objc protocol in empty extension breaks with EXC_BAD_INSTRUCTION

。_饼干妹妹 提交于 2019-12-02 05:13:30
Been having lots and lots of trouble with Swift protocols in combination with arrays, but I couldn't even reproduce my whole problem before things started to break in playground. Here's a minimal example. I have two protocols and a class Bus which declares conformance to one of the protocols. In addition, an empty extension of Bus declares conformance to the other protocol: import Foundation @objc protocol Displayable { var name: String {get} } @objc protocol Utterable { var utterance: String {get} } class Bus : Displayable { var name = "a bus"; var utterance = "this is a bus"} extension Bus :

What is lldb_expr in Swift Playground?

橙三吉。 提交于 2019-12-01 22:41:58
问题 I was trying to demonstrate basic inheritance to someone and how the super initializer is always called by default when overriding an init: class Animal{ init(){ println("Animal has been initialized!") } } class Dog:Animal{ var feet:Int = 4 override init(){ println("Dog has been initialized!") } } var d = Dog() Why is it that I get {__lldb_expr_380.Animal feet 4} on the last line? It goes away when I create an instance variable under the animal class. 回答1: I am not 100% about this but to me

Empty Class in Swift Playground Gives __lldb_expr_ Error

梦想与她 提交于 2019-12-01 22:15:52
问题 Knocking up an empty class within a Swift Playground gives an error __lldb_expr_ //: Playground - noun: a place where people can play import UIKit class FooBar { } let foo = FooBar() See attached screenshot. This occurs on Xcode Version 6.3.1 (6D1002) . I have also tried with the latest Xcode 6.4 beta 3 - Version 6.4 (6E7) - available 11th May 2015. The same error occurs. Empty classes build without issue in a normal Swift project. The error can be avoided by simply adding a dummy constant as

Empty Class in Swift Playground Gives __lldb_expr_ Error

戏子无情 提交于 2019-12-01 20:44:39
Knocking up an empty class within a Swift Playground gives an error __lldb_expr_ //: Playground - noun: a place where people can play import UIKit class FooBar { } let foo = FooBar() See attached screenshot. This occurs on Xcode Version 6.3.1 (6D1002) . I have also tried with the latest Xcode 6.4 beta 3 - Version 6.4 (6E7) - available 11th May 2015. The same error occurs. Empty classes build without issue in a normal Swift project. The error can be avoided by simply adding a dummy constant as follows: //: Playground - noun: a place where people can play import UIKit class FooBar { let wibble =