在Swift中使用Predicate从Azure移动服务查询表

时间:2014-09-24 02:58:19

标签: ios azure swift

我正在尝试使用Swift中的Predicate来查询我的Azure移动服务。 但是,我正在执行查询,并且不返回任何内容。即使我将列名更改为不存在的内容,我也不会从Azure移动服务返回任何错误消息,也不会检索任何记录。

是否有人能够发现我在这里所做的任何明显错误的事情?感谢您提供的任何指导。以下是一些相关代码:

var usersTable : MSTable?
var records = [NSDictionary]()
let userID = UIDevice().identifierForVendor.UUIDString
let userCheckPredicate = NSPredicate(format: "userid == %@", userID)
usersTable!.readWithPredicate(userCheckPredicate) {
            result, totalCount, error  in

    if error != nil {
                println("Error: " + error.description)
                return
            }
    records = result as [NSDictionary]
    println("Information: retrieved %d records", result.count)

我还尝试用单引号括住%@,但没有不同的结果。

1 个答案:

答案 0 :(得分:0)

NSPredicate语法不正确。

我的谓词需要说:

let userCheckPredicate = NSPredicate(format: "userid == [c] %@", userID)