【问题标题】:How to query all user with Kinvey in iOS with swift?如何使用 swift 在 iOS 中使用 Kinvey 查询所有用户?
【发布时间】:2016-02-02 05:16:24
【问题描述】:

这是在 Kinvey 中查询用户的示例代码,但是如果我不输入特定信息,则会出现错误。如何查询所有用户(在 Swift 中)?

    //Find all the Smiths
    KCSUserDiscovery.lookupUsersForFieldsAndValues(
[ KCSUserAttributeSurname : "Smith" ],
completionBlock: { (objectsOrNil: [AnyObject]!, errorOrNil: NSError!) -> Void in
    if errorOrNil == nil {
        //array of matching KCSUser objects
        NSLog("Found %d Smiths", objectsOrNil.count)
    } else {
        NSLog("Got An error: %@", errorOrNil)
    }
},
progressBlock: nil

)

【问题讨论】:

    标签: ios swift kinvey


    【解决方案1】:

    您可以通过直接从Users 集合中读取来获取用户列表。下面的代码展示了如何做到这一点 -

            let collection = KCSCollection.userCollection()
            let store = KCSAppdataStore(collection: collection, options: nil)
    
            store.queryWithQuery(KCSQuery(), withCompletionBlock: { (objectsOrNil: [AnyObject]!, error: NSError!) -> Void in
                //objectsOrNil is a list of users 
            }, withProgressBlock: nil)
    

    请注意,对您的用户集合的权限可能会保护某些用户不会出现在您的结果中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多