草庐IT

swift - Pinterest-iOS 2.3 和 Swift : calling createPinWithImageURL results in EXC_BAD_ACCESS

coder 2023-09-09 原文

使用 Pinterest-IOS SDK (2.3) 我在通过 Swift Bridge 创建 SDK 的实例然后调用 createPinWithImageURL 时收到 EXC_BAD_ACCESS 错误。当将相同的代码转换回 objective-c,然后从 Swift 调用包装器方法时,它按预期工作。根本原因似乎是将 appID 和后缀字符串从 Swift 传递到 Objective-C。

此代码失败:

self.pinterest = Pinterest(clientId:"your_app_id", urlSchemeSuffix:"prod")!
if(pinterest.canPinWithSDK()) {
    pinterest.createPinWithImageURL(NSURL(string: imageUrl)!, sourceURL:NSURL(string: sourceUrl)!, description:pinDescription)
}

在 objective-c 端设置 appId 时成功:

    self.bainterest = PinterestWrapper.sharedInstance()
    baPinterest.pinRecipe(imageUrl, sourceURL:sourceUrl, description:pinDescription)

我创建了一个项目来证明这一点:

Sample Project

最佳答案

        var pinterest:Pinterest = Pinterest()
        pinterest.setValue("your_app_id", forKey: "clientId")
        if(pinterest.canPinWithSDK()){
            pinterest.createPinWithImageURL(imageUrl, sourceURL:sourceUrl, description:pinDescription)
        }

修复功能

关于swift - Pinterest-iOS 2.3 和 Swift : calling createPinWithImageURL results in EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27668986/

有关swift - Pinterest-iOS 2.3 和 Swift : calling createPinWithImageURL results in EXC_BAD_ACCESS的更多相关文章

随机推荐