SDWebimage2.4-2.7 版本 if ([[info valueForKey:@"type"] isEqualToString:@"background"])

1.1 出现bug前截图

2789393-3251df04a771424b.jpg

1.2 出现bug后解决截图

2789393-ca6e65aa75d94e03.png

崩溃日志

Bad_Access_exc 内存泄漏。

官方文档解释

苹果文档:

Dispatch Objective-C Messages Using the Method Function’s Prototype

An exception to the casting rule described above is when you are calling the objc_msgSend function or any other similar functions in the Objective-C runtime that send messages. Although the prototype for the message functions has a variadic form, the method function that is called by the Objective-C runtime does not share the same prototype. The Objective-C runtime directly dispatches to the function that implements the method, so the calling conventions are mismatched, as described previously. Therefore you must cast the objc_msgSend function to a prototype that matches the method function being called.

Listing 2-14 shows the proper form for dispatching a message to an object using the low-level message functions. In this example, the doSomething: method takes a single parameter and does not have a variadic form. It casts the objc_msgSend function using the prototype of the method function. Note that a method function always takes an id variable and a selector as its first two parameters. After the objc_msgSend function is cast to a function pointer, the call is dispatched through that same function pointer

总结

objc_msgSend要明确指向消息转发的对象类型及其返回类型。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 转至元数据结尾创建: 董潇伟,最新修改于: 十二月 23, 2016 转至元数据起始第一章:isa和Class一....
    40c0490e5268阅读 1,858评论 0 9
  • Runtime是什么 Runtime 又叫运行时,是一套底层的 C 语言 API,其为 iOS 内部的核心之一,我...
    SuAdrenine阅读 912评论 0 3
  • 本文详细整理了 Cocoa 的 Runtime 系统的知识,它使得 Objective-C 如虎添翼,具备了灵活的...
    lylaut阅读 844评论 0 4
  • 文/熠歆 材料:胡萝卜,西葫芦,土豆,鸡蛋两个 步骤: 1、将胡萝卜切丝,土豆先切丝然后切碎,西葫芦也是切碎 2、...
    熠歆阅读 1,133评论 2 4
  • Git & SVN 什么是SSH KEY 参考文章http://www.liaoxuefeng.com/wiki/...
    冰J冰阅读 3,641评论 0 2