freesuraj/SPAnalogClock

Crash on iPhone 6 Simulator

Closed this issue · 7 comments

App crashes right after the start on Xcode 6 GM and iPhone 6 Simulator. On the other hand it works fine on iPhone 5S on both iOS 7.1 and iOS 8.

Crashlog:

2014-09-15 11:21:03.522 Clock[1647:171070] -[__NSCFCalendar timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x7fed8af09930
2014-09-15 11:21:03.526 Clock[1647:171070] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFCalendar timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x7fed8af09930'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010d4643f5 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010d0fdbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010d46b50d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010d3c37fc ___forwarding___ + 988
    4   CoreFoundation                      0x000000010d3c3398 _CF_forwarding_prep_0 + 120
    5   CoreFoundation                      0x000000010d3a9700 -[__NSCFCalendar components:fromDate:] + 208
    6   CoreFoundation                      0x000000010d3a95be -[_NSCopyOnWriteCalendarWrapper components:fromDate:] + 78
    7   Clock                               0x000000010b6d1c6c -[SPClockView timerFired:] + 284
    8   QuartzCore                          0x000000010d96c8f7 _ZN2CA7Display15DisplayLinkItem8dispatchEv + 37
    9   QuartzCore                          0x000000010d96c7bf _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 315
    10  CoreFoundation                      0x000000010d3cc4e4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    11  CoreFoundation                      0x000000010d3cc0a5 __CFRunLoopDoTimer + 1045
    12  CoreFoundation                      0x000000010d38f3dd __CFRunLoopRun + 1901
    13  CoreFoundation                      0x000000010d38ea06 CFRunLoopRunSpecific + 470
    14  GraphicsServices                    0x000000010fd529f0 GSEventRunModal + 161
    15  UIKit                               0x000000010b9bb550 UIApplicationMain + 1282
    16  Clock                               0x000000010b6cc643 main + 115
    17  libdyld.dylib                       0x000000010dd17145 start + 1
    18  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

@burczyk this app was intended to run on iOS 7 and above.
it crashes because it cannot find this method in ios 6:

  • (void)drawInRect:(CGRect)rect withAttributes:(NSDictionary *)attrs
    its only available in IOS 7 and upwards.

you can make it work by replacing this method with the following one:

  • (void)drawInRect:(CGRect)rect
    wherever necessary

thanks

@mythodeia I think you are not correct. iPhone 6 Simulator works only on iOS 8 and the problem occurs in method: - (void)timerFired:(id)sender in line

NSDateComponents *weekdayComponents = [gregorian components:(NSDayCalendarUnit | NSWeekdayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:_time];

Tried to debug this issue but this is the furthest I can get. Don't know if it's not a bug in iOS 8.

@burczyk
i misread and though the 6 was referring on IOS 6 not iPhone 6. Sorry about that!
can you check this http://stackoverflow.com/questions/12743198/nsdatecomponents-on-ios6-not-working
and see if it helps

@mythodeia thanks for the link but it doesn't tell me much. The only thing that I see different is replacing explicit gregorian calendar with [NSCalendar currentCalendar]. But in this project it doesn't change anything - it still crashes.

@burczyk sorry Burczyk, I haven't really tested it for iOS 8. So I'm not sure if any methods are depreciated. I'll update it once I have time to play around with iOS 8.

@burczyk i have encountered the same issue today building the framework on iPhone 6. In my case to fix the problem i have only changed the property declaration:

@Property (assign, nonatomic) NSDate *time;

to:

@Property (readwrite, nonatomic) NSDate *time;

and the variable is back assignable.

@mskappa @burczyk @freesuraj
i can confirm that with @Property (nonatomic, readwrite) NSDate *time;
it does not crash !