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