ios - 如何解决此错误 "Cannot invoke getObejectAtPath with argument list type of string"

标签 ios swift restkit

我正在配置restkit,但遇到类似错误

"cannot invoke getObjectAtPath" with argument list.....

那么如何解决这个问题,我也想全局编写函数。

func fatchingData() {
        var queryParams = ""
        var path = "property_type/"
        RKObjectManager.sharedManager().getObjectsAtPath(path, parameters: queryParams, success: { operation, mappingResult in

            self.resultData = mappingResult.array()


            },
            failure:{ operation, error in
                println("error")
            }
        )
    }

最佳答案

queryParams 有问题。您将其声明为 String,但它必须是 Dictionary

这里是它的示例代码:

func loadVenues() {
    let latLon = "37.33,-122.03" // approximate latLon of The Mothership (a.k.a Apple headquarters)
    let queryParams = [
        "ll": latLon,
        "client_id": kCLIENTID,
        "client_secret": kCLIENTSECRET,
        "categoryId": "4bf58dd8d48988d1e0931735",
        "v" : "20140617"
    ]

    RKObjectManager.sharedManager().getObjectsAtPath("/v2/venues/search", parameters: queryParams,
        success:{ operation, mappingResult in
            self.venues = mappingResult.array()
            self.tableView.reloadData()
        },
        failure:{ operation, error in
            NSLog("What do you mean by 'there is no coffee?': \(error!.localizedDescription)")
        }
    )
}

引用HERE .

希望有帮助。

关于ios - 如何解决此错误 "Cannot invoke getObejectAtPath with argument list type of string",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32201274/

相关文章:

iphone - RestKit 一对多反向关系(没有 CoreData)

ios - Restkit POST ManagedObjectRequestOperation 或 ObjectRequestOperation?

ios - Expo iOS 构建不工作 - -"Could Not Receive Latest API Key from App Store Connect"

ios - 如何从 NSManagedObject 属性派生核心数据属性键?

ios - 重新限制 UIButton 的宽度

ios - RestKit 0.20.0 rc1 - 使用字符串数组创建请求帖子

ios - 如何检测 iOS 中是否连接了 HFP 或 A2DP?

ios - SWIFT 代码 dataWithContentsOfFile 因更新到 XCode 6.1 而损坏

ios - Swift:if语句中的预期声明错误

iOS Animate UIPicker 高度变化