import UIKit
class ViewController: UIViewController {
var gruppe = ["new york", "sydney", "paris"]
@IBAction func knopf(sender: UIButton) {
println(gruppe[0])
}
}
答案 0 :(得分:1)
您可以尝试以下方式:
// File 1
import UIKit
class ViewController: UIViewController {
@IBAction func knopf(sender: UIButton) {
println(DataClass.gruppe()[0])
}
}
// File 2
class DataClass {
class func gruppe() -> [String] {
return ["new york", "sydney", "paris"]
}
}
答案 1 :(得分:0)
You can bridge a Swift array to a NSArray
做类似的事情:
let cocoaArray : NSArray = gruppe
cocoaArray.writeToFile("pathToYourFile", atomically:true)