更新OS X到El Capitan和Core Plot崩溃:



更新了10.11的操作系统我试着在优胜美地运行我的项目但核心情节有些奇怪这是一个崩溃日志,有什么想法吗?

2015-10-02 00:18:48.097 checkMyMac[2410:186855] *** -[NSArrayM .insertObject:atIndex:]: object不能为nil 2015-10-02 00:18:48.098checkMyMac[2410:186855] (0 CoreFoundation
)0x00007fff95f55bd2 __exceptionPreprocess + 178 1 libobjc.A.dylib
0x00007fff9bc284fa objc_exception_throw + 48 2 CoreFoundation
0x00007fff95e6c370 checkForCloseTag + 0 3 CorePlot
0x0000000100108a79 CPTPushCGContext + 169 4 CorePlot
0 x0000000100108938-[NSAttributedString(CPTPlatformSpecificAttributedStringExtensions) drawwinrect:inContext:] + 40 5 CorePlot
0x00000001000f6016 -[CPTTextLayer renderAsVectorInContext:] + 694 6
CorePlot 0x00000001000f70f5 -[CPTLayer . CorePlotdrawwincontext:] + 85 7 QuartzCore
0x00007fff9681fcdd _ZN2CA5Layer8display_Ev + 649 8 CorePlot
0x00000001000f708b -[CPTLayer display] + 91 9 QuartzCore
0 x00007fff96811e51 _ZN2CA5Layer17display_if_neededEPNS_11TransactionE+ 603 10 QuartzCore 0x00007fff96811979 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 35 11 QuartzCore 0x00007fff96810e4d_ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277 12 QuartzCore 0x00007fff96810a98_ZN2CA11Transaction6commitEv + 508 13 QuartzCore 0x00007fff9681c28f_zn2ca11transaction17observer_callbackkep19__cfrunloopobservermpv + 71 14 CoreFoundation 0x00007fff95eeae07__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION
+ 23 15 CoreFoundation 0x00007fff95eead77__CFRunLoopDoObservers + 391 16 CoreFoundation 0x00007fff95ec9d58 CFRunLoopRunSpecific + 328 17 HIToolbox
0x00007fff8a4e0d55 RunCurrentEventLoopInMode + 235 18 HIToolbox
0x00007fff8a4e0a97 ReceiveNextEventCommon + 184 19 HIToolbox
0x00007fff8a4e09cf _BlockUntilNextEventMatchingListInModeWithFilter +71 20 AppKit 0x00007fff8aed2f3a_DPSNextEvent + 1067 21 AppKit 0x00007fff8aed2369 -[NSApplication . net_nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454 22 AppKit 0x00007fff8aec6ecc -[NSApplication . net+ 682 23 AppKit 0x00007fff8ae90162NSApplicationMain + 1176 24 libdyld.dylib
0x00007fff8c85f5ad start + 1 25 ??
0x0000000000000003 0x0 + 3

从git hub下载了一个新的core plot拷贝编译为框架和相同的故事:-(

)

好的,我修改了源代码如果有人有同样的问题,这是我的(不太好的)解决方案

文件名为CPTTextLayer.m

-(void)renderAsVectorInContext:(CGContextRef)context
{
    if ( self.hidden ) {
        return;
    }

    //////////////////////////////////////////////////
    //Added by me to avoid crash when self.text
    // or self.attributedText is nil
    //////////////////////////////////////////////////
    if (!self.text || !self.attributedText)
    {
        return;
    }
    ///////////////////////////////////////////////////
    NSString *myText = self.text;
    if ( myText.length > 0 ) {
        [super renderAsVectorInContext:context];
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
        CGContextSaveGState(context);
        CGContextTranslateCTM(context, CPTFloat(0.0), self.bounds.size.height);
        CGContextScaleCTM( context, CPTFloat(1.0), CPTFloat(-1.0) );
#endif
        CGRect newBounds = CGRectInset(self.bounds, kCPTTextLayerMarginWidth, kCPTTextLayerMarginWidth);
        newBounds.origin.x += self.paddingLeft;
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
        newBounds.origin.y += self.paddingTop;
#else
        newBounds.origin.y += self.paddingBottom;
#endif
        newBounds.size.width  -= self.paddingLeft + self.paddingRight;
        newBounds.size.height -= self.paddingTop + self.paddingBottom;

        NSAttributedString *styledText = self.attributedText;


        if ( (styledText.length > 0) && [styledText respondsToSelector:@selector(drawInRect:)] ) {
            [styledText drawInRect:newBounds
                         inContext:context];
        }
        else {
            [myText drawInRect:newBounds
                 withTextStyle:self.textStyle
                     inContext:context];
        }
    #if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
        CGContextRestoreGState(context);
    #endif
    }
}

这是一个已知的问题,已经在release-2.0分支上修复了。详情请参阅Core Plot issue #210

最新更新