Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSURL初始化容易crash #711

Closed
ganvinalix opened this issue Jan 20, 2017 · 6 comments
Closed

NSURL初始化容易crash #711

ganvinalix opened this issue Jan 20, 2017 · 6 comments

Comments

@ganvinalix
Copy link

ganvinalix commented Jan 20, 2017

`
require('UIWebView, NSURL,NSURLRequest,JPSpecialInit,UIView')

defineClass('RecommendViewController', {
quickEntrance: function(sender) {
var url = NSURL.alloc().initWithString("http://www.apple.com");
console.log('js viewDidLoad end');
}
})
`
界面有多个按钮,其点击事件都进入quickEntrance。在界面上狂点那妞不到一分钟几乎百分百crash

iphone7plus iOS10.2 xcode: 8.2.1 jspatch:1.1.2

@ganvinalix
Copy link
Author

@bang590 换成 var url = NSURL.alloc().init(); 也一样。

@ganvinalix
Copy link
Author

tmp6efc2e54

@ganvinalix
Copy link
Author

image

@ganvinalix
Copy link
Author

第一:测试发现使用 NSURL 的 URLWithString 函数不会crash了。NSURL的初始化建议使用URLWithString;
第二:期待知道为什么这样

@ghost
Copy link

ghost commented Feb 6, 2017

should be same reason with #705

@ghost ghost mentioned this issue Feb 6, 2017
@ghost
Copy link

ghost commented Feb 6, 2017

此问题与#248 原因相同。
均因ClassName.alloc()返回值为同一个,通过**__bridge_transfer**转换所有权之后导致后续初始化混乱。
建议使用class方法来初始化。

@bang590 bang590 closed this as completed Feb 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants