UIKit/Webkit/UIWebViewPDF/UIWebView/UIWebDocumentView/…上的NullSafe崩溃。。。自iOS8以来
好的,这个iOS8开始引起很多问题,这就是其中之一 我使用的是NullSafe库(可以在github上找到),它在解析空内容时基本上返回nil而不是异常 现在,当NullSafe工作时,它只需浏览所有类(从项目中的每个框架/捆绑包/工具包)。我对这个Nullsafe库为什么会这样做的理解不是很有信心,但它确实这样做了,现在它崩溃了 调试时,崩溃时检查的类会有所不同,但我们在apple文档或捆绑包中找不到它。。。因此,我的结论是: 似乎NullSafe正在尝试浏览不存在的类UIKit/Webkit/UIWebViewPDF/UIWebView/UIWebDocumentView/…上的NullSafe崩溃。。。自iOS8以来,ios,null,crash,ios8,Ios,Null,Crash,Ios8,好的,这个iOS8开始引起很多问题,这就是其中之一 我使用的是NullSafe库(可以在github上找到),它在解析空内容时基本上返回nil而不是异常 现在,当NullSafe工作时,它只需浏览所有类(从项目中的每个框架/捆绑包/工具包)。我对这个Nullsafe库为什么会这样做的理解不是很有信心,但它确实这样做了,现在它崩溃了 调试时,崩溃时检查的类会有所不同,但我们在apple文档或捆绑包中找不到它。。。因此,我的结论是: 似乎NullSafe正在尝试浏览不存在的类 我真的无法摆脱Nul
- 我真的无法摆脱NullSafe,或者至少我想尝试一下 暂时停止李>
- 它似乎总是在与视图相关时崩溃 上课
- 当我们寻找它们时,它们似乎从来都不存在
//
// NullSafe.m
//
// Version 1.2.1
//
// Created by Nick Lockwood on 19/12/2012.
// Copyright 2012 Charcoal Design
//
// Distributed under the permissive zlib License
// Get the latest version from here:
//
// https://github.com/nicklockwood/NullSafe
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
#import <objc/runtime.h>
#import <Foundation/Foundation.h>
#ifndef NULLSAFE_ENABLED
#define NULLSAFE_ENABLED 1
#endif
#pragma GCC diagnostic ignored "-Wgnu-conditional-omitted-operand"
@implementation NSNull (NullSafe)
#if NULLSAFE_ENABLED
- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector
{
@synchronized([self class])
{
//look up method signature
NSMethodSignature *signature = [super methodSignatureForSelector:selector];
if (!signature)
{
//not supported by NSNull, search other classes
static NSMutableArray *classList = nil;
static NSMutableDictionary *signatureCache = nil;
if (signatureCache == nil)
{
classList = [[NSMutableArray alloc] init];
signatureCache = [[NSMutableDictionary alloc] init];
//get class list
int numClasses = objc_getClassList(NULL, 0);
Class *classes = (Class *)malloc(sizeof(Class) * (unsigned long)numClasses);
numClasses = objc_getClassList(classes, numClasses);
//add to list for checking
NSMutableSet *excluded = [NSMutableSet set];
for (int i = 0; i < numClasses; i++)
{
//determine if class has a superclass
Class someClass = classes[i];
Class superclass = class_getSuperclass(someClass);
while (superclass)
{
if (superclass == [NSObject class])
{
[classList addObject:someClass];
}
Class next = class_getSuperclass(superclass);
[excluded addObject:NSStringFromClass(superclass)];
superclass = next;
}
}
//remove all classes that have subclasses
for (Class someClass in [classList reverseObjectEnumerator])
{
if ([excluded containsObject:NSStringFromClass(someClass)])
{
[classList removeObject:someClass];
}
}
//free class list
free(classes);
}
//check implementation cache first
NSString *selectorString = NSStringFromSelector(selector);
signature = [signatureCache objectForKey:selectorString];
if (!signature)
{
//find implementation
for (Class someClass in classList)
{
if ([someClass instancesRespondToSelector:selector])
{
signature = [someClass instanceMethodSignatureForSelector:selector];
break;
}
}
//cache for next time
[signatureCache setObject:signature ?: [NSNull null] forKey:selectorString];
}
else if ([signature isKindOfClass:[NSNull class]])
{
signature = nil;
}
}
return signature;
}
}
- (void)forwardInvocation:(NSInvocation *)invocation
{
[invocation invokeWithTarget:nil];
}
#endif
@end
//
//NullSafe.m
//
//版本1.2.1
//
//由Nick Lockwood于2012年12月19日创作。
//版权所有2012木炭设计
//
//根据许可的zlib许可证分发
//从此处获取最新版本:
//
// https://github.com/nicklockwood/NullSafe
//
//本软件按“原样”提供,无任何明示或暗示
//保证书。在任何情况下,提交人都不对任何损害负责
//由于使用本软件而产生的。
//
//允许任何人出于任何目的使用本软件,
//包括商业应用程序,并对其进行修改和重新发布
//自由,受以下限制:
//
// 1. 不得歪曲本软件的来源;你不能
//声称您编写了原始软件。如果你使用这个软件
//在产品中,产品文档中的确认是
//感谢,但不是必需的。
//
// 2. 更改后的源版本必须清楚地标记为这样,并且不得更改
//被误传为原始软件。
//
// 3. 不得从任何源分发中删除或更改此通知。
//
#进口
#进口
#ifndef NULLSAFE_已启用
#定义NULLSAFE_已启用1
#恩迪夫
#pragma GCC诊断被忽略“-Wgnu条件省略操作数”
@实现NSNull(NullSafe)
#如果启用了NULLSAFE_
-(NSMethodSignature*)方法签名选择器:(SEL)选择器
{
@已同步([自类])
{
//查找方法签名
NSMethodSignature*signature=[super methodSignatureForSelector:selector];
如果(!签名)
{
//NSNull不支持,请搜索其他类
静态NSMutableArray*classList=nil;
静态NSMutableDictionary*signatureCache=nil;
if(signatureCache==nil)
{
classList=[[NSMutableArray alloc]init];
signatureCache=[[NSMutableDictionary alloc]init];
//获取类列表
int numclass=objc_getClassList(NULL,0);
Class*classes=(Class*)malloc(sizeof(Class)*(unsigned long)numclass);
numclass=objc_getClassList(类,numclass);
//添加到列表以进行检查
NSMutableSet*已排除=[NSMutableSet];
for(int i=0;i
希望这有帮助:)