Comments (1)
使用performSelectorWithArgs获取返回的对象,会直接释放
在getReturnFromInv:withSig:方法里
case '@': { // id
id ret = nil;
[inv getReturnValue:&ret];
return ret;
};
如果在id前面加上__autoreleasing就没有问题了,但是不知道具体原因是什么
原因是在arc模式下,getReturnValue:仅仅是从invocation的返回值拷贝到指定的内存地址,如果返回值是一个NSObject对象的话,是没有处理起内存管理的。而我们在定义returnValue时使用的是__strong类型的指针对象,arc就会假设该内存块已被retain(实际没有),当returnValue出了定义域释放时,导致该crash。假如在定义之前有赋值的话,还会造成内存泄露的问题。
NSObject *returnValue = nil;
// 有返回值类型,才去获得返回值
if (signature.methodReturnLength != 0)
{
void *tempReturnValue;
[invocation getReturnValue:&tempReturnValue];
returnValue = (__bridge NSObject *)tempReturnValue;
}
response(returnValue, nil);
from yycategories.
Related Issues (20)
- 希望拓展支持层面,添加对 macOS 的支持 HOT 1
- UIDevice+YYAdd 添加iPhone 8 && iPhone X设备.
- pageController style on TableViewcell static
- 10 warnings
- 编译warning什么时候能出个新版本?
- 交换类方法为什么获取方法实现用的是实例方法呢?
- Please fix this warning
- imageByRoundCornerRadius: corners: borderWidth: borderColor: borderLineJoin方法图片偏小
- YYSYNTH_DYNAMIC_PROPERTY_CTYPE的getter返回值类型错误 HOT 1
- ipAddressWIFI 返回来的地址不对
- 这个库貌似不更新了?
- UIView
- UIView类别的问题
- 文字高度计算偏高
- ibireme快醒醒,你已经两年没有更新这个库了
- 严重Bug!NSObject + YYAddForKVO 中添加 观察者后,无法真正移除观察者! HOT 1
- 这个库支持swift吗
- Any Plan support Apple Privacy Manifest for cocoapods ? HOT 3
- 麻烦增加PrivacyInfo文件 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yycategories.