相关疑难解决方法(0)

如何使用swift playground打印到控制台?

我一直在关注苹果指南的新语言swift,但我不明白为什么右边的栏只显示"Hello,playground"而不是"Hello,world".有人可以解释为什么println没有在右边打印?

// Playground - noun: a place where people can play

import Cocoa

var str = "Hello, playground"

println("Hello, world");
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

swift xcode6 swift-playground

97
推荐指数
4
解决办法
11万
查看次数

你如何在swift 2中做println()

我似乎无法找到如何println()在Swift 2中做.

我试过了 println(helloworld)

这不起作用

helloworld是一个变量

ios swift swift2

9
推荐指数
2
解决办法
2万
查看次数

快速写入文件的有效方式

我正在使用蓝牙从传感器获取数据,我想将获得的数据字符串附加到文件末尾。

当我尝试常规方法时

if let dir = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.AllDomainsMask, true).first {
        let path = NSURL(fileURLWithPath: dir).URLByAppendingPathComponent(self.file)

        do {
            try text.writeToURL(path, atomically: false, encoding: NSUTF8StringEncoding)
        }
        catch {/* error handling here */}
Run Code Online (Sandbox Code Playgroud)

我的应用程序开始变慢,直到标签不再更新。

尝试dispatch_async在后台线程中使用,但它仍然减慢了我的应用程序的速度。

我应该使用什么方法?我阅读了有关流的内容,但未能迅速找到一些我可以依赖的解决方案

ios swift

3
推荐指数
1
解决办法
3087
查看次数

打印角色在同一个游乐场swift 3

在同一行打印字符

for i in 1...5
  {
     print(i)
  }
Run Code Online (Sandbox Code Playgroud)

操作需要像

12345
Run Code Online (Sandbox Code Playgroud)

但是印刷品就像

1
2
3
4
5
Run Code Online (Sandbox Code Playgroud)

任何人都有解决方案.

ios swift-playground swift3

1
推荐指数
1
解决办法
2769
查看次数

标签 统计

ios ×3

swift ×3

swift-playground ×2

swift2 ×1

swift3 ×1

xcode6 ×1