草庐IT

playground

全部标签

swift - 为什么我的 Printable 实现在 Swift playground 中不起作用?

在Swiftplayground中考虑这段代码:importCocoaclassThing:Printable{letname:Stringinit(){name="something"}vardescription:String{returnname}}leta=Thing()println("hello,\(a)")作为图像:预期:我希望最后一行打印“hello,something”。观察:它打印“你好,__lldb_expr_1.Thing”,就好像我没有实现Printable协议(protocol)一样。该代码实际上在真实iOS应用程序的上下文中运行,它按预期使用Printab

swift - 将类从 Playground 页面导入到另一个页面

注意:这是一个不同的question而不是导入通用的swift文件(可以使用Sources文件夹完成)。我有一个有2页的Playground,我想在第二页中使用第一页中定义的协议(protocol)。我将使用JSON转换的示例。JSON.xcplaygroundpageimportFoundationprotocolJSONConvertible{funcjsonValue()->String}JSONArray.xcplaygroundpageimportFoundation//UndeclaredtypeJSONConvertibleextensionArray:JSONConve

swift - Playground Xcode 永远不会停止运行,有什么想法吗?

我一直在学习Swift,并且始终遇到一个反复出现的问题。playground在运行时并没有完成代码的运行,即使是默认的MyPlayground文件也是如此。我没有得到任何输出。我在网上搜索过,其他人和我有同样的问题,但没有答案。对于我之前创建的默认文件和构建文件,会发生这种情况。我在3个不同的场合与Apple交谈,但一无所获,并引用了开发者论坛,他们也没有得到答复。有什么想法吗?例如,//:Playground-noun:aplacewherepeoplecanplayimportCocoavarstr="Hello,playground"print(str)这是默认设置,在运行时,我

swift - (SWIFT) 错误 : Playground execution aborted: error: Execution was interrupted, 原因 : EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, 子代码=0x0)

我收到这个错误代码错误:Playground执行中止:错误:执行被中断,原因:EXC_BAD_INSTRUCTION(代码=EXC_I386_INVOP,子代码=0x0)。进程一直停留在中断点,使用"threadreturn-x"返回到表达式求值前的状态。这是我的代码:importCocoaimportSpriteKitimportPlaygroundSupportpublicclassScene:SKScene{varpoint=CGPoint(x:0,y:0)letviewFrame=CGRect(x:0,y:0,width:1080,height:1080)overrideini

xcode - Swift 版本 1.2 在 Xcode 6.3 的 Playground 中不可用?

Xcode6.3Beta(6D520o)的新功能之一应该是let语句的更改行为。在Swift1.2中,您应该可以稍后为let常量赋值。不仅与声明。只要你在使用之前初始化了一个值,一切都应该没问题。但是通过我的小测试,我仍然会遇到与过去相同的错误。letedge:CGFloatedge=CGFloat(44.55)println(edge)不能给‘let’值‘edge’赋值Xcode6.3BetaPlayground是否仍在使用Swift1.1而不是1.2?在我的Xcode中,我有菜单项“Convert>ToSwift1.2”,但它被禁用了。有什么方法可以从Swift本身获取当前版本号的

ios - iPad 上的 Swift Playground 可以包含多个源文件吗?

我只是想知道这是否可能:我在Xcode上打开了一个playground,其中包含多个.swift源文件,可通过public访问器访问。在iPad的SwiftPlaygrounds上也能实现同样的效果吗? 最佳答案 是的,这是可能的。在Apple的网站上,他们声明:Becauseyou’reworkingwithrealcode,youcanimportandexportdirectlybetweenSwiftPlaygroundsandXcode.Soyoucantryoutyourideaswiththetoolprosuseto

ios - 为什么它不能在 swift 2 的 Playground 上显示任何东西?

我尝试使用spriteKit在助理编辑器的Playground上展示一些东西。然而,什么也没有显示。下面是代码。如果有人可以显示结果(蓝色矩形),请通知我。如果不是,请找出问题所在。importUIKitimportSpriteKitletview:SKView=SKView(frame:CGRectMake(0,0,1000,800))letscene:SKScene=SKScene(size:CGSizeMake(1000,800))scene.scaleMode=SKSceneScaleMode.AspectFitletblueBox:SKSpriteNode=SKSpriteN

swift - 将自定义 key 添加到 info.plist,当我从 Swift 中的 Playground 访问时,它是零

使用Xcode7.2(在Yosemite上),我似乎无法从playground的info.plist访问自定义key:importUIKitvarstr="Hello,playground"letapp_id=NSBundle.mainBundle().infoDictionary?["MyAppID"]as?String使用上面的代码,app_id为nil。我希望它是字符串“TEST”我像这样将它包含在我的info.plist中:Playground是否有一些我没有读过的限制?如果我打印所有的key,我的自定义key就丢失了:letdict=NSBundle.mainBundle()

swift - 为什么我不能在 Playground 中使用 AVURLAsset 从媒体文件中提取数据?

在我的Playground上:importCocoaimportFoundationimportAVFoundationvarpath2="/Users/me/Movies/bukesiyi.mp4"varvideo2=NSURL(fileURLWithPath:path2,isDirectory:false)//itshows:file:///Users/me/Movies/bukesiyi.mp4video2.checkResourceIsReachableAndReturnError(nil)//it'struevarasset=AVURLAsset(URL:video2)//i

ios - 如何在 Swift playground 中停止帧的大小变为 1024x768

UIViewController中主视图的frame变为1024x768一开始问题不明显,后来做布局的时候就麻烦了。如何确保框架与我使用.preferredContentSize设置的大小保持相同?importUIKitimportPlaygroundSupportclassMyViewController:UIViewController{overrideopenfuncviewDidLoad(){super.viewDidLoad()self.view.backgroundColor=UIColor.whiteself.view.frame//Whenrunplaygroundsh