美文网首页
SDWebimage2.4-2.7 版本 if ([[info

SDWebimage2.4-2.7 版本 if ([[info

作者: smkoc | 来源:发表于2017-11-06 11:12 被阅读0次

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要明确指向消息转发的对象类型及其返回类型。

相关文章

网友评论

      本文标题:SDWebimage2.4-2.7 版本 if ([[info

      本文链接:https://www.haomeiwen.com/subject/yfakmxtx.html