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

Reloading of calendar view crashing app. #597

Closed
gabhisekdev opened this issue Feb 27, 2017 · 4 comments
Closed

Reloading of calendar view crashing app. #597

gabhisekdev opened this issue Feb 27, 2017 · 4 comments

Comments

@gabhisekdev
Copy link

Hi, I am trying to reload the calendarView before implementing the following code :

func calendar(_ calendar: FSCalendar, hasEventFor date: Date) -> Bool {
        
        let dateString: String = DateUtil.stringFromDate(date: date, withFormat: DateFormats.frmtDateAPIUrl,withLocalConversion: false)! //returns date in YYYY-mm-dd format
        
        if bookingDateArray.count == 0{
            if bookingDateArray.contains(dateString){
                return true
            }
            else{
                return false
                
            }
        }
        
        return false
        
    }

bookingDateArray is an array of dates which I receive from server side. I reload the calendar view as :

DispatchQueue.main.async {
           self.calendar.reloadData()
       }

Issue - Its resulting in application crash with error as -

[__NSCFCalendar components:fromDate:toDate:options:]: toDate 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                      0x052aa3b7 -[__NSCFCalendar components:fromDate:toDate:options:] + 295
	1   CoreFoundation                      0x052aa217 -[_NSCopyOnWriteCalendarWrapper components:fromDate:toDate:options:] + 103
	2   FSCalendar                          0x01bb68a6 -[FSCalendar isDateInRange:] + 438
	3   FSCalendar                          0x01bba1f2 -[FSCalendar reloadDataForCell:atIndexPath:] + 2002
	4   FSCalendar                          0x01badc53 -[FSCalendar collectionView:cellForItemAtIndexPath:] + 531
	5   UIKit                               0x0373f446 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 463
	6   UIKit                               0x0373f270 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 73
	7   UIKit                               0x03744dbc -[UICollectionView _updateVisibleCellsNow:] + 6560
	8   UIKit                               0x0374a9b9 -[UICollectionView layoutSubviews] + 318
	9   UIKit                               0x02e03374 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1457
	10  libobjc.A.dylib                     0x0497e1b9 -[NSObject performSelector:withObject:] + 59
	11  QuartzCore                          0x02a3474d -[CALayer layoutSublayers] + 141
	12  QuartzCore                          0x02a27a2b _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 401
	13  QuartzCore                          0x02a27881 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 21
	14  QuartzCore                          0x029b14c7 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 339
	15  QuartzCore                          0x029e02b8 _ZN2CA11Transaction6commitEv + 498
	16  QuartzCore                          0x029e0daa _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 124
	17  CoreFoundation                      0x0526a76e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
	18  CoreFoundation                      0x0526a6c7 __CFRunLoopDoObservers + 391
	19  CoreFoundation                      0x0524e3a6 __CFRunLoopRun + 1414
	20  CoreFoundation                      0x0524dbab CFRunLoopRunSpecific + 395
	21  CoreFoundation                      0x0524da0b CFRunLoopRunInMode + 123
	22  GraphicsServices                    0x084a1b4c GSEventRunModal + 177
	23  GraphicsServices                    0x084a19c7 GSEventRun + 80
	24  UIKit                               0x02d2e32b UIApplicationMain + 148
	25  Naher                               0x0003bfd1 main + 145
	26  libdyld.dylib                       0x06d8a799 start + 1
)

So any ways to resolve this .... ?

@WenchaoD
Copy link
Owner

WenchaoD commented Mar 2, 2017

Hi @GABHISEKBUNTY Can you provide a sample project url which reproduces and demonstrates your issue, with the latest version of code?

@gabhisekdev
Copy link
Author

FSClndrDemo.zip

@gabhisekdev
Copy link
Author

Please check the zipped app. On pressing of reload data, its throwing the above mentioned logs in the console and not reloading the data.

@WenchaoD
Copy link
Owner

WenchaoD commented Mar 7, 2017

@GABHISEKBUNTY You are using 2.7.0. Try 2.7.3.

@WenchaoD WenchaoD closed this as completed Mar 7, 2017
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

2 participants