草庐IT

PlayGround

全部标签

快速 Playground 错误 BAD_INSTRUCTION

所以我有下面的贪心算法,它给了我以下错误:Playgroundexecutionaborted:error:Executionwasinterrupted,reason:EXC_BAD_INSTRUCTION(code=EXC_I386_INVOP,subcode=0x0).Theprocesshasbeenleftatthepointwhereitwasinterrupted,use"threadreturn-x"toreturntothestatebeforeexpressionevaluation.类://Thisclassrepresentsanundirectedgraphu

swift - Playground Book 中的 iOS 11 框架 (CoreML)

我最近在尝试访问CoreML框架时遇到了PlaygroundBooks的奇怪行为。首先,CoreML确实适用于纯.playground文件,如Apple的示例“MarsHabitatModel”所示。在.playgroundbook中复制相同的源文件时,PlaygroundBook无法编译并引发Error:MLModelisonlyavailableoniOSapplicationextension11.0ornewer.我确保将.playgroundbook的Manifest.plist文件中的部署目标设置为iOS11.0。因此,我非常不确定CoreML是否或如何在Playgroun

swift - Swift Playground 中的 AVAudioFile 结果为 "error -54"

我决定在SwiftPlayground中玩AVAudioPlayer。以下代码在普通Swift项目中运行良好,但在Playground中(在辅助编辑器中)运行时返回以下错误:2015-05-1200:08:04.374AVAudioFile[2481:141158]00:08:04.374ERROR:AVAudioFile.mm:266:AVAudioFileImpl:error-54代码如下:importCocoaimportAVFoundationvaraudioFileURL=NSURL(fileURLWithPath:"/Users/scooby/Desktop/song.wa

带有字典的 Swift playground 太慢了

我在Xcode7.1中使用以下代码创建了一个Swiftplayground,其评估速度非常慢(通常需要几分钟)。为什么会这样?由于它使playground基本上无法使用,我可以采取任何措施来缩短其执行时间吗?letsets=["TEMPERATURE":[(value:37.0,attributes:["A":0.0,"B":0.2]),(value:37.5,attributes:["A":0.0,"B":1.0]),(value:38.0,attributes:["A":0.2,"B":0.5]),(value:38.5,attributes:["A":0.5,"B":0.2]),

ios - 字符串代码数组的文本文件在 Playground 中有效,但在 Xcode 项目中无效

我有以下代码创建一个名为num.txt的文本文件的字符串数组importFoundationimportUIKitfunclinesFromResource(fileName:String)throws->[String]{guardletpath=NSBundle.mainBundle().pathForResource("num",ofType:"txt")else{throwNSError(domain:NSCocoaErrorDomain,code:NSFileNoSuchFileError,userInfo:[NSFilePathErrorKey:fileName])}let

ios - Playground——DispatchQueue和DispatchSemaphore的关系

我对DispatchQueue和DispatchSemaphore感到困惑。就像下面的例子:letsemaphore:DispatchSemaphore=DispatchSemaphore(value:1)foriin1...40{DispatchQueue.global().async{semaphore.wait()NSLog("......1-%d",i)semaphore.signal()}}我认为它应该打印1...40,实际上它只打印了大约25,结果如下:2016-11-1819:05:38.786MyPlayground[7436:495171]......1-12016-

swift - 关于 Swift Playground 中的 UIImage

我在我的项目中创建了一个swiftplayground。但是当我添加这个时varimg2=UIImage(named:"Demo")它给了我以下控制台输出:Playgroundexecutionfailed:error:Executionwasinterrupted,reason:EXC_BAD_ACCESS(code=1,address=0x20).Theprocesshasbeenleftatthepointwhereitwasinterrupted,use"threadreturn-x"toreturntothestatebeforeexpressionevaluation.*t

ios - 如何在项目目录中的 Xcode 中打开一个 Playground?

我正在使用swift构建iOS。项目模板似乎没有playground文件。我转到文件>>新建>>Playground>>命名我的文件>>将Playground文件放在我的项目目录中。我在侧边栏目录中查找它,但它不存在。然后我转到Finder并导航到该项目,我可以看到该文件。它应该出现在项目目录中吗? 最佳答案 我来晚了,但它可能对环顾四周的其他人有帮助,它很简单,只需打开xCode转到File>Open>选择您上次创建playground项目的目录最后选择fileName.playground(扩展名为.playgorund的文件)

ios - 如何在 Swift Playground 中获取布局跟踪

我正在SwiftPlayground中制作一些View的原型(prototype)。importUIKitimportXCPlaygroundletcontainerView=UIView(frame:CGRect(origin:CGPointZero,size:CGSize(width:320,height:300)))XCPShowView("ContainerView",containerView)我正在使用此容器View放入一些View并使用约束对其进行布局。现在我真的很想从中得到一个LayoutTrace,就像来自po[[UIWindowkeyWindow]_autolayo

Swift : Difference between sources and resources folders in playground file? 为什么 sources 文件夹有 swift 标志?

swiftplayground文件中的Sources和Resources文件夹有什么区别?为什么Sources文件夹上有swift标志?我们可以在每个文件夹中放入什么? 最佳答案 Sources用于支持您希望playground可用的Swift源代码。Resources用于资源文件,如图像、plist等。 关于Swift:Differencebetweensourcesandresourcesfoldersinplaygroundfile?为什么sources文件夹有swift标志?,我