2014-09-22 3 views
0

좋아요.이 iOS8이 많은 문제를 일으키기 시작했는데, 그 중 하나입니다.UIKit/Webkit/UIWebViewPDF/UIWebView/UIWebDocumentView/... 이후 iOS8에서 NullSafe 충돌이 발생합니다.

무언가를 파싱 할 때 기본적으로 예외 대신 nil을 반환하는 NullSafe 라이브러리 (github에서 찾을 수 있음)를 사용하고 있습니다.

NullSafe가 작동 중일 때 프로젝트의 모든 프레임 워크/번들/키트에서 모든 클래스를 탐색합니다. 나는이 Nullsafe 라이브러리가 왜 그런지에 대한 이해에 확신이 가지 않는다. 그러나 실제로 그것을한다. 그리고 그것은 지금 부서진다. 디버깅, 클래스가 달라 충돌 할 때 확인되고 있지만, 우리가 어디 사과 문서 또는 번들에서 찾을 수 없다

는 ... 그래서 내 결론은 다음과 같습니다

NullSafe 탐색하려고 것 같습니다 정말 NullSafe 삭제되지 않거나, 적어도 내가 당분간하지 을 시도하고 싶습니다

  • 존재하지 않는 클래스.
  • 항상 관련된보기 클래스에서 충돌하는 것으로 보입니다.
  • 우리가 그들을 찾을 때 결코 존재하지 않는 것 같습니다.

아무도 NullSafe를 사용하거나 그것에 대해 아는 사람이 있습니까?

답변

0

Nick (Nullsafe 제작자)에게 문의 한 후 내 문제가 사라지는 것을 보았습니다. 그는 방금 최신 버전 1.2.1을주었습니다.

// 
// 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 파일입니다
관련 문제