Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[__NSCFCalendar dateByAddingComponents:toDate:options:]: date cannot be nil plaint, then further violations will simply silently do whatever random thing results from the nil. #36

Open
appmake opened this issue Feb 7, 2014 · 9 comments
Assignees

Comments

@appmake
Copy link

appmake commented Feb 7, 2014

2014-02-07 16:24:07.435 YoJo[11443:70b] *** -[__NSCFCalendar dateByAddingComponents:toDate:options:]: date cannot be nil
I mean really, what do you think that operation is supposed to mean with a nil date?
An exception has been avoided for now.
A few of these errors are going to be reported with this complaint, then further violations will simply silently do whatever random thing results from the nil.

@MosheBerman
Copy link
Owner

Where did you see this error? Can you provide more information? What did you do to invoke this?

@bci
Copy link

bci commented Jul 21, 2014

Ok, I received these errors when I am using Min and Max date to limit the days shown on the calendar:

_calendar = [CKCalendarView new];
[_calendar setDelegate:self];
[_calendar setDataSource:self];
[_calendar setMinimumDate:firstDate]; 
[_calendar setMaximumDate:lastDate]; 
(firstDate __NSDate *   2014-07-13 20:08:00 PDT 0x000000010f724ef0)
(lastDate __NSDate *    2014-08-03 20:08:00 PDT 0x000000010f7152d0)

When I comment out:

[_calendar setMinimumDate:firstDate]; 
[_calendar setMaximumDate:lastDate]; 

It all works fine. I thought I was calling this wrong, so I've ignored it... I was going to work on this as the users wanted an indication of the dates on which I requested data.

Here is the backtrace where this occurred this time (some frames may be missing due to compiler optimizations):

(
    0   CoreFoundation                      0x0000000102a8322c -[__NSCFCalendar components:fromDate:] + 108
    1   CoreFoundation                      0x0000000102b125e9 -[_NSCopyOnWriteCalendarWrapper components:fromDate:] + 73
    2   HRA-Mobile                          0x0000000100006f18 -[NSCalendar(Components) daysInDate:] + 72
    3   HRA-Mobile                          0x000000010002adef -[NSCalendar(DateComparison) date:isSameDayAs:] + 127
    4   HRA-Mobile                          0x000000010000ea39 -[CKCalendarView _layoutCellsAnimated:] + 3161
    5   HRA-Mobile                          0x000000010000daa3 -[CKCalendarView layoutSubviewsAnimated:] + 1395
    6   HRA-Mobile                          0x0000000100010c5b -[CKCalendarView setDate:animated:] + 1211
    7   HRA-Mobile                          0x0000000100010db2 -[CKCalendarView setMinimumDate:animated:] + 162
    8   HRA-Mobile                          0x0000000100010cf4 -[CKCalendarView setMinimumDate:] + 100
    9   HRA-Mobile                          0x00000001000095b3 -[SelectRankingsDateViewController viewDidLoad] + 851
    10  UIKit                               0x00000001018e059e -[UIViewController loadViewIfRequired] + 562
    11  UIKit                               0x00000001018e0777 -[UIViewController view] + 29
    12  UIKit                               0x00000001018f72c5 -[UINavigationController _startCustomTransition:] + 628
    13  UIKit                               0x00000001019026f5 -[UINavigationController _startDeferredTransitionIfNeeded:] + 401
    14  UIKit                               0x0000000101903238 -[UINavigationController __viewWillLayoutSubviews] + 43
    15  UIKit                               0x0000000101a1d895 -[UILayoutContainerView layoutSubviews] + 202
    16  UIKit                               0x000000010184a993 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 354
    17  QuartzCore                          0x00000001015f8802 -[CALayer layoutSublayers] + 151
    18  QuartzCore                          0x00000001015ed369 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 363
    19  QuartzCore                          0x00000001015ed1ea _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    20  QuartzCore                          0x0000000101560fb8 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 252
    21  QuartzCore                          0x0000000101562030 _ZN2CA11Transaction6commitEv + 394
    22  QuartzCore                          0x000000010156269d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
    23  CoreFoundation                      0x0000000102a41dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    24  CoreFoundation                      0x0000000102a41d37 __CFRunLoopDoObservers + 391
    25  CoreFoundation                      0x0000000102a21522 __CFRunLoopRun + 946
    26  CoreFoundation                      0x0000000102a20d83 CFRunLoopRunSpecific + 467
    27  GraphicsServices                    0x00000001030abf04 GSEventRunModal + 161
    28  UIKit                               0x00000001017eae33 UIApplicationMain + 1010
    29  HRA-Mobile                          0x00000001000401b3 main + 115
    30  libdyld.dylib                       0x0000000103c8b5fd start + 1
    31  ???                                 0x0000000000000001 0x0 + 1
)

@MosheBerman
Copy link
Owner

Thanks, I'll look into it.

@gurupatel
Copy link

screen shot 2014-07-24 at 4 36 17 pm
screen shot 2014-07-24 at 4 36 24 pm

The above same error I am also receiving commented by @bci & how to restrict calendar to draw dates starting from 01-04-2014 to current date only, Can anybody please help me.

I am doing like this : -
NSDate *max = [NSDate dateWithDay:25 month:7 year:2014];
NSDate *min = [NSDate dateWithDay:1 month:4 year:2014];

 [[self calendarView] setMaximumDate:max];
 [[self calendarView] setMinimumDate:min];

But it will print only start date & end date didn't appears dates between that range, please check attached screen short. Thanks in advance.

@MosheBerman
Copy link
Owner

I've added a check to the NSCalendar category that is calling the method that's logging those errors, but I haven't necessarily fixed the issues with minimum and maximum dates. Version 2.2.2 does add a fix and unit test for date comparisons which may fix this problem. Please have another look, @gurupatel and let me know if 2.2.2 works any better.

@bci
Copy link

bci commented Mar 14, 2016

Revisited with MBCalendatKit at version 3.0.4 (via pod update)

[_calendar setMinimumDate:firstDate]; 
[_calendar setMaximumDate:lastDate]; 

Still receiving error below, and dates are only from 3/6/2016 - 3/13/2016, others blank.
Errors occur also when only using one of the limits.

2016-03-13 16:58:59.014 HRA-Mobile[76775:3763278] -[SelectRankingsDateViewController viewDidLoad] [Line 52] firstDate: 2016-03-07 00:58:59 +0000, lastDate:: 2016-03-27 23:58:59 +0000

2016-03-13 16:58:59.067 HRA-Mobile[76775:3763278] *** -[__NSCFCalendar components:fromDate:]: date cannot be nil
Future exception.
A few of these errors are going to be reported with this complaint, then further violations will simply be ignored.
Here is the backtrace where this occurred this time (some frames may be missing due to compiler optimizations):
(
    0   CoreFoundation                      0x03321d17 -[__NSCFCalendar components:fromDate:] + 119
    1   CoreFoundation                      0x03321c29 -[_NSCopyOnWriteCalendarWrapper components:fromDate:] + 89
    2   Foundation                          0x005070ae -[NSAutoCalendar components:fromDate:] + 58
    3   HRA-Mobile                          0x00143265 -[NSCalendar(Components) daysInDate:] + 101
    4   HRA-Mobile                          0x001435d7 -[NSCalendar(DateComparison) date:isSameDayAs:] + 151
    5   HRA-Mobile                          0x00137690 -[CKCalendarView _layoutCellsAnimated:] + 3392
    6   HRA-Mobile                          0x00136451 -[CKCalendarView layoutSubviewsAnimated:] + 1553
    7   HRA-Mobile                          0x00139d11 -[CKCalendarView setDate:animated:] + 1489
    8   HRA-Mobile                          0x00139eaf -[CKCalendarView setMinimumDate:animated:] + 175
    9   HRA-Mobile                          0x00139dd2 -[CKCalendarView setMinimumDate:] + 98
    10  HRA-Mobile                          0x00100329 -[SelectRankingsDateViewController viewDidLoad] + 1001
    11  UIKit                               0x01baf2ae -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 44
    12  UIKit                               0x01bb3dce -[UIViewController loadViewIfRequired] + 1384
    13  UIKit                               0x01bba406 -[UIViewController __viewWillAppear:] + 114
    14  UIKit                               0x01bdd5b9 -[UIViewController(UIContainerViewControllerProtectedMethods) beginAppearanceTransition:animated:] + 202
    15  UIKit                               0x01bef9cc -[UINavigationController _startCustomTransition:] + 1389
    16  UIKit                               0x01c01769 -[UINavigationController _startDeferredTransitionIfNeeded:] + 803
    17  UIKit                               0x01c02ada -[UINavigationController __viewWillLayoutSubviews] + 68
    18  UIKit                               0x01ddec4a -[UILayoutContainerView layoutSubviews] + 252
    19  UIKit                               0x01ab4008 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810
    20  libobjc.A.dylib                     0x02ecc059 -[NSObject performSelector:withObject:] + 70
    21  QuartzCore                          0x009d480a -[CALayer layoutSublayers] + 144
    22  QuartzCore                          0x009c84ee _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
    23  QuartzCore                          0x009c8352 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    24  QuartzCore                          0x009bae8b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
    25  QuartzCore                          0x009eee03 _ZN2CA11Transaction6commitEv + 561
    26  QuartzCore                          0x009f0674 _ZN2CA11Transaction17flush_transactionEv + 50
    27  UIKit                               0x01a18dfa _afterCACommitHandler + 197
    28  CoreFoundation                      0x0330fffe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    29  CoreFoundation                      0x0330ff5e __CFRunLoopDoObservers + 398
    30  CoreFoundation                      0x033058dc __CFRunLoopRun + 1340
    31  CoreFoundation                      0x033050e6 CFRunLoopRunSpecific + 470
    32  CoreFoundation                      0x03304efb CFRunLoopRunInMode + 123
    33  GraphicsServices                    0x05c12664 GSEventRunModal + 192
    34  GraphicsServices                    0x05c124a1 GSEventRun + 104
    35  UIKit                               0x019e7bfa UIApplicationMain + 160
    36  HRA-Mobile                          0x001277ca main + 138
    37  libdyld.dylib                       0x03e0aa21 start + 1
)

@MosheBerman MosheBerman reopened this Mar 14, 2016
@MosheBerman MosheBerman self-assigned this Mar 14, 2016
@MosheBerman
Copy link
Owner

Thanks for the feedback. I'll investigate when I have some spare time.

@MosheBerman
Copy link
Owner

MBCalendarKit 5.0.0 adopts Objective-C nullability modifiers and some API introduced in iOS 8. This should improve things, but I didn't have time to focus on this issue with this update. Let me know if 5.0.0 still has this and I'll take it into consideration on a near-future 5.x.0.

@MosheBerman
Copy link
Owner

Found the issue today when trying to work on #105 and #61. Should be fixed in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants