好吧所以我只是将Xcode更新为7.3,现在我收到了这个警告:
'var'参数已弃用,将在Swift 3中删除
当我需要在此函数中使用var时,如何解决这个问题:
public func getQuestionList(var language: String) -> NSArray {
if self.data.count > 0 {
if (language.isEmpty) {
language = "NL"
}
return self.data.objectForKey("questionList" + language) as! NSArray
}
return NSArray()
}
Run Code Online (Sandbox Code Playgroud) 我得到以下错误:"无法赋值:'word'是'let'常数"我无法弄清楚为什么会发生这种情况.如果有人可以帮助我,我会非常感激.
这是代码:
import UIKit
class ViewController: UIViewController {
var word1 = ""
@IBOutlet weak var label: UILabel!
func writeWord(word: String){
word = "Example"
}
@IBAction func button(sender: AnyObject) {
writeWord(word1)
label.text = word1
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Run Code Online (Sandbox Code Playgroud) 我一直在关注成功查询表的Microsoft Azure 文档(插入,读取和更新项目到数据库工作正常),但在一个简单的方法结束时,直接关闭文档:
func getAllEventIDs() -> [String] {
var events:[String] = [] //this is to be updated
let delegate = UIApplication.sharedApplication().delegate as! AppDelegate
let client = delegate.client! //boiler-plate for azure
let itemTable = client.tableWithName("Events")
itemTable.query().readWithCompletion {
//something about this query block might be preventing successful initialization to the events array
(result:MSQueryResult!, error) in
//usually error-checking here
for item in result.items {
events.append(item.valueForKey("id") as! String)
//returning events here...
}
//...and here (almost) work, since Swift expects a return of type …Run Code Online (Sandbox Code Playgroud)