Pinterest SDK how to get a PDKPin's link?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 20:16:48

问题


It seems that there is a dictionary value I can place in the GET call that corresponds to a property on PDKPin that I can call in my success block to unpack the value, i.e. "url" = PDKPin.url "note" = PDKPin.decriptionText, however I can't find a corresponding property for "link" which is available per the documentation https://developers.pinterest.com/docs/api/pins/?

    PDKClient.sharedInstance().getAuthenticatedUserPinsWithFields(Set(["url", "note", "link"]), success:
            { (responseObject :PDKResponseObject!) -> Void in
            print("success /(pdk)")


                let currentResponseObject = responseObject
            let pins = currentResponseObject.pins
            self.pinArray = pins()




            for pin in self.pinArray {
                if let pinAsPDKPin = pin as? PDKPin {

                    print(pinAsPDKPin.descriptionText)


                    if let safeURL = pinAsPDKPin.url {
                        print(safeURL)
                    }


                    let link = pinAsPDKPin.link //no such property on PDKPin
                }
            }


        }) { (err :NSError!) -> Void in
            print("error NSError: \(err)")
    }

回答1:


It looks kinda weird, but as per the implementation, the 'link' property(from the API) is used as 'url'(in the SDK). Check out the code here : https://github.com/pinterest/ios-pdk/blob/master/Pod/Classes/PDKPin.m#L38

So, if all that you care about is the 'link' from the API, then just access 'url' in the SDK(in PDKPin object).



来源:https://stackoverflow.com/questions/34474573/pinterest-sdk-how-to-get-a-pdkpins-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!