小编alt*_*tag的帖子

在swift,iOS游乐场中读取文件

在搜索了许多(很多!)快速游乐场问题甚至制作这些代码后,我仍然在苦苦挣扎.

我已经将一个文本文件放在Resources包内容的文件夹中,它在playground(/var/folders/ ...)生成的运行临时文件中显示为别名(链接).

import UIKit

let bundle = NSBundle.mainBundle()

let myFilePath = bundle.pathForResource("dict1", ofType: "txt")

println(myFilePath)    // <-- this is correct, there is a shortcut to the Resource file at this location

var error:NSError?

var content = String(contentsOfFile:myFilePath!, encoding:NSUTF8StringEncoding, error: &error)

println(content!)  // <-- this is *NOT* the file contents [EDIT: see later note]

// Demonstrate there's no error
if let theError = error {
    print("\(theError.localizedDescription)")
} else {
    print("No error")
}
Run Code Online (Sandbox Code Playgroud)

问题是,content …

xcode ios swift swift-playground

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

我可以在不使用 ul 或 ol 的情况下使用 Vue v-for

我是 Vue 的新手。我想显示一些数据行,但我不想要数字 (ol) 或项目符号 (ul)。下面有替代我的方法吗?

<li v-for="product in contract.products">
  <div class="p-1 row">
    <div class="col-4">
      <strong>{{ product.productName }}</strong>
    </div>
    <div class="col-4">
      Allocation: {{ product.allocation }}
    </div>
    <div class="col-4">
      Fulfilled:  {{ product.allocationFulfilled }}
    </div>
  </div>
</li>
Run Code Online (Sandbox Code Playgroud)

非常感谢。

vue.js bootstrap-4 v-for

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

标签 统计

bootstrap-4 ×1

ios ×1

swift ×1

swift-playground ×1

v-for ×1

vue.js ×1

xcode ×1