草庐IT

PlayGround

全部标签

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

Swift playground 显示错误的语句执行次数(forEach on array)

我一直在探索仿函数,但在理解forEach仿函数在幕后的作用时遇到了一些困难。例如,当我将其输入Playground时:letarray=[1]//[1]array.forEach{$0.value}//(3times)array.forEach{_inprint("hello")}//(2times)当我展开(3times)或(2times)时,它只显示()其中一个,为什么对1个元素的数组执行多次,为什么两次forEach计算的执行次数不同? 最佳答案 这是一个相当困惑的情况。让我们首先考虑第二个forEach:array.for

swift - 为什么 Swift playground 显示错误的执行次数?

我正在使用完成处理程序来汇总数字。我不明白的是,如果我将代码分成两行,执行次数将从6次变为7次!!为什么?funcsummer(from:Int,to:Int,handler:(Int)->(Int))->Int{varsum=0foriinfrom...to{sum+=handler(i)}returnsum}summer(1,to:6){//Shows'21'return$0}//shows'(6times)'//Samecode,butin1linesummer(1,to:6){return$0}//shows'(7times)'图片 最佳答案

swift - `Calendar` API 崩溃 Swift Playground

简单的Playground:importFoundation//letc1=Calendar.sharedletc2=Calendar(identifier:.gregorian)我在两者之间切换,在运行playground时都给出相同的错误:error:Executionwasinterrupted,reason:EXC_BAD_ACCESS(code=EXC_I386_GPFLT).我正在运行Xcode9beta2 最佳答案 它在Xcode9.0GM中工作。正如Hamish所说,测试版软件存在缺陷。:)

ios - 如何将桥接头添加到 Xcode Playground?

是否可以使用Bridging-Header文件将ObjectiveC头文件包含到XcodePlayground? 最佳答案 我不这么认为。无法使用import让Playground识别框架,即使此框架是正确配置了Bridging-Header的项目的一部分。 关于ios-如何将桥接头添加到XcodePlayground?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/296965

ios - Playground 执行失败 : error: Couldn't lookup symbols

我正在使用Xcode7.3。我已经将Playground和Frameworks放在同一个工作区中并构建了框架。我仍然收到此错误Playgroundexecutionfailed:error:Couldn'tlookupsymbols:_RestofireVersionNumber如何解决? 最佳答案 如果您的库有.podspec,您可以使用cocoapods-playgrounds生成一个应该可以工作的Playground。$geminstallcocoapods-playgrounds$podplaygroundsRestofir

swift - swift 中的内存安全(输入参数/长期访问)

我正在阅读swift中的内存安全章节,想试试这个例子:varstepSize=1funcincrement(_number:inoutInt){number+=stepSize}increment(&stepSize)如果它说由于对stepsize变量的访问冲突(以书面形式长期访问)而出现错误,它实际上会编译并给我正确的答案(即2)。任何人都可以举例说明长期访问变量何时会导致错误吗?我不能带一个。编辑:我在Xcode9.2上用playground进行了测试 最佳答案 它将在playground中运行-playground不是一个完美