[英]EXC BAD ACCESS error
I am using Tapku calendar on my project .In the method for selecting a date 我在项目上使用Tapku日历。在选择日期的方法中
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. do on方法显示另一个视图。 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 . 但是,单击日期后,它将显示该视图。但是,在那之后,系统显示EXC_BAD_ACCESS.Any idea ..我正在尝试但找不到错误。 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 这是initWithTimeCards方法
-(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). 尝试启用NSZombies来查看哪个对象被过度释放(这很可能是您的问题)。
See How do I set up NSZombieEnabled in Xcode 4? 请参阅如何在Xcode 4中设置NSZombieEnabled? 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. 编辑 :此外,请务必检查-initWithTimeCards
和-getTimeCardWithStartData:endDate:timeCardType
方法,看看你过度释放在那里的东西。
EDIT 2 : The issue is probably that some of your arrays isn't retained properly in memory. 编辑2 :问题可能是您的某些数组未正确保留在内存中。 Try changing fetchedSyncedTimeCards
to self.fetchedSyncedTimeCards
and do the same with fetchedNotSyncedTimeCards
. 尝试将fetchedSyncedTimeCards
更改为fetchedSyncedTimeCards
, self.fetchedSyncedTimeCards
进行相同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. 您可能要在-fetchTimceCardWithSyncStatus
返回一个自动释放的对象,并且此后不保留它,从而导致程序对不再分配的对象调用方法。
But even if it works, you should really read up on memory management and make sure your code doesn't leak everywhere. 但是,即使它可行,您也应该认真阅读内存管理 ,并确保您的代码不会到处泄漏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.