简体   繁体   中英

EXC BAD ACCESS error

I am using Tapku calendar on my project .In the method for selecting a date

i showed another view on the view.Here is my code

- (void)calendarMonthView:(TKCalendarMonthView *)monthView didSelectDate:(NSDate *)date {

    self.dataController=[[TimeCardDataController alloc] init];
    self.dataController.managedObjectContext=[self context];
    [self.dataController initWithTimeCards];

    NSDate *weekStartDay=[date weekFirstDate];
    NSDate *weekEndDay=[date weekLastDate];
    self.billdailyValuePositiveArray= [self.dataController getTimeCardWithStartData:date endDate:date timeCardType:TIMECARD_STATUS_BILLABLE];   
    self.billweeklyValueNegetiveArray= [self.dataController getTimeCardWithStartData:weekStartDay endDate:weekEndDay timeCardType:TIMECARD_STATUS_NONBILLABLE];
    self.billweeklyValuePositiveArray= [self.dataController getTimeCardWithStartData:weekStartDay endDate:weekEndDay timeCardType:TIMECARD_STATUS_BILLABLE];
    self.billdailyValueNegetiveArray= [self.dataController getTimeCardWithStartData:date endDate:date timeCardType:TIMECARD_STATUS_NONBILLABLE];

    self.syncweeklyValuePositiveArray=[self.dataController getTimeCardWithStartData:weekStartDay endDate:weekEndDay timeCardType:TIMECARD_STATUS_SYNCED];
    self.syncweeklyValueNegetiveArray=[self.dataController getTimeCardWithStartData:weekStartDay endDate:weekEndDay timeCardType:TIMECARD_STATUS_NOTSYNCED];
    self.syncdailyValuePositiveArray= [self.dataController getTimeCardWithStartData:date endDate:date timeCardType:TIMECARD_STATUS_SYNCED];
    self.syncdailyValueNegetiveArray= [self.dataController getTimeCardWithStartData:date endDate:date timeCardType:TIMECARD_STATUS_NOTSYNCED];

    self.postweeklyValuePositiveArray= [self.dataController getTimeCardWithStartData:weekStartDay endDate:weekEndDay timeCardType:TIMECARD_STATUS_POSTED];
    self.postweeklyValueNegetiveArray= [self.dataController getTimeCardWithStartData:weekStartDay endDate:weekEndDay timeCardType:TIMECARD_STATUS_NOTPOSTED];
    self.postdailyValuePositiveArray= [self.dataController getTimeCardWithStartData:date endDate:date timeCardType:TIMECARD_STATUS_POSTED];
    self.postdailyValueNegetiveArray= [self.dataController getTimeCardWithStartData:date endDate:date timeCardType:TIMECARD_STATUS_NOTPOSTED];


    [self toggleCalendar];

    [self doOn:date];

}

the do on method shows another view. But after clicking a date it shows the view .But after that the system shows EXC_BAD_ACCESS.Any ideas.. I am trying but cant find the error . Please i need help

Here is the code for the methods above:::::::

 -(NSMutableArray *) getTimeCardWithStartData:(NSDate *) startDate endDate:(NSDate *)endDate timeCardType:(NSString *) timeCardType
{
    NSMutableArray* timeCardArray=[[NSMutableArray alloc] init];

    NSMutableArray *categoryTimeCardArray=[[NSMutableArray alloc] init] ;
    if ([timeCardType isEqualToString:TIMECARD_STATUS_BILLABLE]) 
    {
        categoryTimeCardArray=[self fetchedTimeCardWithStartDate:startDate endDate:endDate fetchedCategoryTimeCard:self.fetchedBillableTimeCards];

    }
    else if([timeCardType isEqualToString:TIMECARD_STATUS_NONBILLABLE])
    {
        categoryTimeCardArray=[self fetchedTimeCardWithStartDate:startDate endDate:endDate fetchedCategoryTimeCard:self.fetchedNonBillableTimeCards];

    }
    else if ([timeCardType isEqualToString:TIMECARD_STATUS_POSTED]) 
    {
        categoryTimeCardArray=[self fetchedTimeCardWithStartDate:startDate endDate:endDate fetchedCategoryTimeCard:self.fetchedPostedTimeCards];

    }
    else if([timeCardType isEqualToString:TIMECARD_STATUS_NOTPOSTED])
    {
        categoryTimeCardArray=[self fetchedTimeCardWithStartDate:startDate endDate:endDate fetchedCategoryTimeCard:self.fetchedNotPostedTimeCards];

    }
    else if([timeCardType isEqualToString:TIMECARD_STATUS_SYNCED])
    {
        categoryTimeCardArray=[self fetchedTimeCardWithStartDate:startDate endDate:endDate fetchedCategoryTimeCard:fetchedSyncedTimeCards];

    }

    else if ([timeCardType isEqualToString:TIMECARD_STATUS_NOTSYNCED])
    {
        categoryTimeCardArray=[self fetchedTimeCardWithStartDate:startDate endDate:endDate fetchedCategoryTimeCard:fetchedNotSyncedTimeCards];

    }





    return categoryTimeCardArray;


}               

This is the initWithTimeCards method

    -(void) initWithTimeCards
{
    [self fetchAllTimeCard];
    fetchedTimecards=[[NSArray alloc] init];
    fetchedBillableTimeCards=[[NSArray alloc] init];
    fetchedBillableTimeCards=[[NSArray alloc] init];
    self.fetchedNonBillableTimeCards =[[NSArray alloc] init];
    self.fetchedPostedTimeCards=[[NSArray alloc] init];
    self.fetchedNotPostedTimeCards=[[NSArray alloc] init];
    fetchedSyncedTimeCards=[[NSArray alloc] init];
    fetchedNotSyncedTimeCards=[[NSArray alloc] init];



    self.fetchedNonBillableTimeCards =[self   fetchTimceCardWithBillStatus:TIMECARD_BILL_STATUS_NONBILLABLE];
    self.fetchedPostedTimeCards=[self fetchTimceCardWithPostStatus:TIMECARD_BILL_STATUS_POSTED];
    self.fetchedNotPostedTimeCards=[self fetchTimceCardWithPostStatus:TIMECARD_BILL_STATUS_NOTPOSTED];
    fetchedSyncedTimeCards=[self fetchTimceCardWithSyncStatus:TIMECARD_BILL_STATUS_SYNCED];
    fetchedNotSyncedTimeCards=[self fetchTimceCardWithSyncStatus:TIMECARD_BILL_STATUS_NOTSYNCED];



}

`

Try enabling NSZombies to see which object that's being over-released (that's likely to be your issue).

See How do I set up NSZombieEnabled in Xcode 4? for instructions on how to enable it.

EDIT : Also, make sure to check the -initWithTimeCards and -getTimeCardWithStartData:endDate:timeCardType methods to see if you're over-releasing something in there.

EDIT 2 : The issue is probably that some of your arrays isn't retained properly in memory. Try changing fetchedSyncedTimeCards to self.fetchedSyncedTimeCards and do the same with fetchedNotSyncedTimeCards . You're probably returning an autoreleased object in -fetchTimceCardWithSyncStatus and not retaining it afterwards, causing your program to invoke methods on an object that is no longer allocated.

But even if it works, you should really read up on memory management and make sure your code doesn't leak everywhere.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM