问题
Using the Pinterest-IOS SDK (2.3) I'm getting a EXC_BAD_ACCESS error when creating an instance of the SDK via the Swift Bridge and then calling createPinWithImageURL. When converting the same code back to objective-c and then calling a wrapper method from Swift it works as expected. The root cause seems to be passing the appID and suffix strings from Swift to Objective-C.
This code fails:
self.pinterest = Pinterest(clientId:"your_app_id", urlSchemeSuffix:"prod")!
if(pinterest.canPinWithSDK()) {
pinterest.createPinWithImageURL(NSURL(string: imageUrl)!, sourceURL:NSURL(string: sourceUrl)!, description:pinDescription)
}
This succeeds when setting appId on the objective-c side:
self.bainterest = PinterestWrapper.sharedInstance()
baPinterest.pinRecipe(imageUrl, sourceURL:sourceUrl, description:pinDescription)
I've created a project that demonstrates this:
Sample Project
回答1:
var pinterest:Pinterest = Pinterest()
pinterest.setValue("your_app_id", forKey: "clientId")
if(pinterest.canPinWithSDK()){
pinterest.createPinWithImageURL(imageUrl, sourceURL:sourceUrl, description:pinDescription)
}
funziona correttamente
来源:https://stackoverflow.com/questions/27668986/pinterest-ios-2-3-and-swift-calling-createpinwithimageurl-results-in-exc-bad-ac