0

I have a main view controller with a button that takes you to the calendar view (which I am using MBCalendarKit for). That and the calendar work just fine. The problem is when I try to go back to the main view from the calendar by tapping the back button on the navigation bar, the app crashes. The only message I get is "Thread 1: EXC_BAD_ACCESS(code=1, address=0xa000010)

Here is my code:

#import "KFBCalendar.h"
#import "NSDate+Components.h"

@interface KFBCalendar ()
@property NSMutableDictionary* eventsDict;
@end

@implementation KFBCalendar

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    CKCalendarView *calendar = [CKCalendarView new];

    [calendar setDelegate:self];
    [calendar setDataSource:self];

    [[self view]addSubview:calendar];

    NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"MM/dd/yyyy HH:mm"];

    // NSMutableDictionary* eventsDict = [[NSMutableDictionary alloc] init];
    _eventsDict = [[NSMutableDictionary alloc] init];
    NSMutableArray* eventsArray = [[NSMutableArray alloc] init];

    CKCalendarEvent* aCKCalendarEvent = [[CKCalendarEvent alloc] init];
    aCKCalendarEvent.date = [dateformatter dateFromString: @"12/04/2013 07:15"];
    aCKCalendarEvent.title = @"Annual Meeting";
    [eventsArray addObject: aCKCalendarEvent];
    [_eventsDict setObject: eventsArray forKey: [NSDate dateWithDay:04 month:12 year:2013]];

    eventsArray = [[NSMutableArray alloc] init];
    aCKCalendarEvent = [[CKCalendarEvent alloc] init];
    aCKCalendarEvent.date = [dateformatter dateFromString: @"12/05/2013 13:30"];
    aCKCalendarEvent.title = @"Annual Meeting";
    [eventsArray addObject: aCKCalendarEvent];
    [_eventsDict setObject: eventsArray forKey: [NSDate dateWithDay:05 month:12 year:2013]];

    eventsArray = [[NSMutableArray alloc] init];
    aCKCalendarEvent = [[CKCalendarEvent alloc] init];
    aCKCalendarEvent.date = [NSDate dateWithDay:6 month:12 year: 2013];
    aCKCalendarEvent.title = @"Annual Meeting";
    [eventsArray addObject: aCKCalendarEvent];
    [_eventsDict setObject:eventsArray forKey:aCKCalendarEvent.date];
}

- (NSArray *)calendarView:(CKCalendarView *)calendarView eventsForDate:(NSDate *)date
{
    return [ self eventsDict][date];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
Moshe
  • 57,511
  • 78
  • 272
  • 425
raginggoat
  • 3,570
  • 10
  • 48
  • 108
  • In which line does it crash? EXC_BAD_ACCESS means that you're trying to reach an released object (that doesn't exist anymore). You could enable NSZombies to get which object causes trouble. – Larme Dec 12 '13 at 15:06
  • Hey, I'm the author of MBCalendarKit. I'm commenting here so I remember to come back in a bit when I have more time to investigate this. – Moshe Oct 05 '14 at 03:43
  • Which line is the crash on? – Moshe Feb 01 '15 at 04:39

0 Answers0