- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用 Pinterest iOS SDK 在我的 iPad 应用程序中分享一个项目。以下代码片段将始终崩溃,并在带有注释的行上发送一条消息发送到已释放的实例
:
NSString *clientId = [NSMutableString stringWithString:@"1431665"];
NSLog(@"clientId: %@", clientId);
Pinterest *pinterest = [[Pinterest alloc] initWithClientId:clientId];
NSLog(@"gone: %@", clientId); // <- CRASH!
我正在使用 NSMutableString stringWithString
来模拟我的应用程序中的条件。我实际上并没有在我的代码中使用该行。
即使不在最后一行输出 clientId
,应用程序也会在离开 block 时崩溃。我假设这是因为 ARC 正在尝试释放已经被释放的引用。
看来 Pinterest SDK 一定是在做一些奇怪的事情,破坏了我传入的字符串。在他们修复代码的同时,我有什么办法可以解决这个问题吗?
编辑 1
简化了测试用例。
编辑 2
看起来 Pinterest SDK 正在使用 clientId
参数。基于clang ARC documentation , 向 clang 表明这一点的方法是用 __attribute((ns_consumed))
来表明这一点。
新问题:是否可以在不修改添加属性的方法签名的情况下向 ARC 指示这一点?
编辑 3
所以这可行,但它丑陋得像罪恶?还有别的办法吗?
NSString *clientId = [NSMutableString stringWithString:@"1431665"];
[clientId performSelector:NSSelectorFromString(@"retain")]; // <- UGLY!
NSLog(@"clientId: %@", clientId);
Pinterest *pinterest = [[Pinterest alloc] initWithClientId:clientId];
NSLog(@"gone: %@", clientId);
最佳答案
我所做的是制作一个代表 Pinterest 类的静态变量:
//I put this outside my @implementation code at the top of my m file
static Pinterest *_pinterest = nil;
// instantiating
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_pinterest = [[Pinterest alloc] initWithClientId:clientId];
});
我认为 Pinterest 假设每个人都会将他们的类用作静态单例,因为这可能是他们内部所做的。公平地说,在大多数情况下,我预计不会在单个应用程序中使用多个客户端 ID。不过,我同意,这是他们的一个令人震惊的疏忽。他们甚至没有记录这种行为,他们在想什么?!
关于ios - 使用 Pinterest SDK 发送到释放实例的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17139092/
我正在细读 http://www.khronos.org/网站,只找到了 OpenCL 的头文件(不是我不关心的 OpenGL)。如何获取 OpenCL SDK? 最佳答案 AMD 的 ATI Str
Android 项目中最低(最低 sdk)和最高(目标 sdk)级别是否有任何影响。这些东西是否会影响项目的可靠性和效率。 最佳答案 没有影响,如果您以 SDK 级别 8 为目标,那么您的应用将以 9
“min sdk version/target sdk version”和“compile sdk version”有什么区别?我知道 min 和 target sdk 是什么意思,但是 compil
我正在尝试运行 Dji Mobile-Sdk-Android:https://github.com/dji-sdk/Mobile-SDK-Android使用 dji 网站上的说明:https://de
我目前正在向我的 iPhone 应用程序添加新的 Facebook iOS sdk 3.1.1。我看到 sdk 有重大变化。例如。我的旧 sdk 创建一个 Facebook 对象并从 FBReques
我最近刚刚下载了 Xcode 4.6 with mac 10.8.4 with iOS 6.0 SDK package,我立即注意到我无法使用我的 iPhone 3Gs with iOS 4.6 进行
我尝试下载 OpenCL SDK。但是没办法。我有一个 AMD GPU,所以我在谷歌上搜索了 AMD SDK,但是来自谷歌的所有链接和一些教程都被破坏了,不可能通过 AMD 开发者网站找到 sdk。
安装 Google Cloud SDK 后,当我运行时 gcloud 授权登录 我收到一条错误消息: Your browser has been opened to visit: https://a
我一直在 nvidia 网站上搜索 GPU 计算 SDK,因为我正在尝试构建具有 cuda 支持的点云库 (PCL)。但是,在 nvidia 网站上,我只能找到工具包的链接,而不是 SDK 的单个下载
Closed. This question needs to be more focused。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅关注editing this post一个问题。 2
当我打开 Android SDK 管理器时,会出现一个屏幕“选择要安装的包”。它列出了一堆带有绿色复选标记(已经安装)的软件包,还有一些带有 x's 的软件包,它们没有安装。如果我选择“全部接受”,它
在开发过程中,我发布了 SDK 21 Lollipop,但我无法在我的 KitKat 设备上使用它。应用程序非常简单,我只将 SDK 用于动画和 Material 设计,但是当我尝试对 Play 商店
enter image description here friend 们好 在使用 Linux、jenkins 和 docker 探索 dotnet 核心时,我遇到了构建问题,该问题在标题“/usr
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我创建了一个flutter项目,运行flutter packages get,输出如下:【二】flutter包搞定等待另一个 flutter 命令释放启动锁...第二次运行“flutter packa
这个问题在这里已经有了答案: What are the Android SDK build-tools, platform-tools and tools? And which version sh
我使用 Corona SDK 已经快一年了,并且开发了几个简单的游戏。我现在正在寻找的是在 Corona SDK 中创建 3D 幻觉的某种方法。如果有人有 Corona 3D 方面的经验,我将不胜感激
我有一个CLDC 1.1 / MIDP 2.0项目,可以使用Java ME SDK 3.2很好地进行编译。 最近,我已将Java SE升级到8,结果Java ME SDK开始在Windows启动时显示
有没有办法以编程方式控制连接到华擎主板的 RGB 照明?我知道华硕有一个 Aura SDK,但华擎是否也有一个用于他们的硬件? 如果是,我在哪里可以找到它? 最佳答案 没有用于华擎多彩的 sdk。但是
如何使用 crm 2011 sdk 和 XrmServiceContext 创建事务? 在下一个示例中,'new_brand' 是一些自定义实体。我想创建三个品牌。第三个拥有错误的 OwnerID g
我是一名优秀的程序员,十分优秀!