nicklockwood / nullsafe Goto Github PK
View Code? Open in Web Editor NEWNullSafe is a simple category on NSNull that returns nil for unrecognised messages instead of throwing an exception
License: Other
NullSafe is a simple category on NSNull that returns nil for unrecognised messages instead of throwing an exception
License: Other
+[NSMethodSignature signatureWithObjCTypes:]: type signature is empty.
We use the latest Nullsafe code in our product and find crashes like this:
SIGSEGV SEGV_ACCERR "-[NSNull(NullSafe) methodSignatureForSelector:] (NullSafe.m:81)"
The reason is that Nullsafe will find all the classes in the system and initialize one instance.
Some classes like UIWebView cannot initialize in background thread thus caused the crash.
A demo code is:
// This code will crash
dispatch_async(dispatch_get_global_queue(0, 0), ^{
UIWebView *v1 = [[UIWebView alloc] init];
[v1 loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]]];
});
Nullsafe's idea is great and we enjoy using it. Can you fix this in the coming version?
XCTest/XCTest.h' file not found。why?
I noticed that installing NullSafe (with Cocoapods) made the following being logged when the app runs:
CLTilesManagerClient: initialize, sSharedTilesManagerClient
CLTilesManagerClient: init
CLTilesManagerClient: reconnecting, 0x7fa1c5288290
This looks like a private Apple framework. Can I ship my app with this?
When compiling NullSafe in Xcode 7 I get the following warning:
NullSafe.m:128:17: warning: null passed to a callee that requires a non-null argument [-Wnonnull] [invocation invokeWithTarget:nil];
It seems like we might be able to remove this call and it resolves the issue (and still works in my tests)
how to handle “< null >” ??
null调用分类里面的链式语法方法还是不能处理,麻烦博主处理一下
crashReason=+[NSMethodSignature signatureWithObjCTypes:]: type signature is empty.
jkhjkghjkj
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
});
在这个线程中 发生了闪退
why not creat a valid method signature to return in - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector
like this NSString *str = @"123"; NSMethodSignature *sign = [str methodSignatureForSelector:@selector(length)]; return sign;
? because in method - (void)forwardInvocation:(NSInvocation *)invocation
you set target to be nil object, so the method signature of invocation is not important.
Because in the forwardInvocation method, set the target of the invocation to nil, so I think,whatever the methodSignature, it doesn't matter. why not just return "v@:" , the simplest methodSignature.
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { NSMethodSignature *signature = [super methodSignatureForSelector:aSelector]; if (!signature) { signature = [NSMethodSignature signatureWithObjCTypes:"v@:"]; } return signature; }
I imported to my project and if I try to set a value to NSNULL class in NSDictionary it crashes.
How to make it work so that it handles all null pointer exemptions.
[someClass instanceMethodSignatureForSelector:selector];
system: iOS12 device:iphone X crash
example:
id test= [NSNull null]
[test isequalTo:xxx] is Crash on IphoneX
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.