iOS9的那些坑 — — WeiboSDK registerApp启动就崩溃
2024-09-30 21:25:27
在升级Xcode7.2.1后,在App加载时直接崩掉,仔细看了,发现是在在注册微博SDK的时候报错:
[WeiboSDK registerApp:WBAPPKey];
查了很多资料,最后在github的微博SDk issue讨论区中发现有人已经解决了。
解决方法:
在注册 微博 sdk 之前
[NSDictionary aspect_hookSelector:NSSelectorFromString(@"weibosdk_WBSDKJSONString")
withOptions:AspectPositionInstead
usingBlock:^(id<AspectInfo> info)
{
return [(NSDictionary*)[info instance] tt_jsonString];
}
error:nil];
tt_jsonString 是自一个字典转字符串的 category;
aspect 可以 pod 安装;
有人解释说,猜测weibosdk使用了旧版本的jsonkit.导致了json的解析兼容性出了问题直接升级微博SDK也可以。
这里提供一个字典转字符串的方法吧:
/** 字典转字符串 */ - (NSString*)dictionaryToJson:(NSDictionary *)dic{ NSError *parseError = nil; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&parseError];return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; }
Aspects的github链接:https://github.com/steipete/Aspects
参考链接: https://github.com/sinaweibosdk/weibo_ios_sdk/issues/133
最新文章
- 详解C#委托,事件与回调函数
- Maven+Spring+MVC结构中,jetty/tomcat是如何启动项目的[转]
- 高仿猫眼电影选座(选票)模块-b
- URL是否有效
- Beyond REST: How to build a HATEOAS API in Java with Spring MVC, Jersey (JAX-RS) and VRaptor
- Linux环境 Mysql新建用户和数据库并授权
- Case of the Zeros and Ones
- Hook SSDT中NtCreateProcessEx
- nodejs 后台服务启动
- 2017最新PHP初级经典面试题目汇总(下篇)
- js基础:对DOM进行操作,删除、添加元素
- 【bzoj 4833】[Lydsy1704月赛]最小公倍佩尔数
- [四] java虚拟机JVM编译器编译代码简介 字节码指令实例 代码到底编译成了什么形式
- Freemaker Replace函数的正则表达式运用
- Linux背背背(6)
- ASP.NET MVC + EF 更新的几种方式
- django中的时区设置TIME_ZONE,USE_TZ
- Java枚举的小用法
- <;Android 基础(二十二)>; EditText 无法显示完全以及尝鲜Android N
- Web | 一小时看懂前端基本语法