小编Evo*_*Sae的帖子

为什么Microsoft Azure(或一般的Swift)无法更新变量以在表查询后返回?

我一直在关注成功查询表的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)

sql iphone azure ios swift

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

标签 统计

azure ×1

ios ×1

iphone ×1

sql ×1

swift ×1