0

カレンダー ビューに移動するボタンを備えたメイン ビュー コントローラーがあります (これには MBCalendarKit を使用しています)。それとカレンダーは問題なく機能します。問題は、ナビゲーション バーの [戻る] ボタンをタップしてカレンダーからメイン ビューに戻ろうとすると、アプリがクラッシュすることです。私が得る唯一のメッセージは「スレッド1:EXC_BAD_ACCESS(コード= 1、アドレス= 0xa000010)です

これが私のコードです:

#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
4

0 に答える 0