好的,所以下面的代码有时会在"// bug !!"下面的行上崩溃
错误是EXC_BAD_ACCESS,据我所知,没有僵尸负责.即使我在for-loop中切换了2行,应用程序仍会在同一行上崩溃.
course是一个课程,它是一个NSManagedObject,包含许多Card对象.我想要做的只是在每个卡片中设置几个属性值.
奇怪的是,当我在循环内尝试NSLog时,bug再也没有出现过.然后,在我注释掉NSLog之后的一段时间,出现了错误.
此外,MBProgressHUD在单独的线程中调用此函数,该函数显示微调器和消息.cardView是UIViewController的子类
- (void)resetLearningData {
// get an array of cards
NSMutableArray *cards = [[course.card allObjects] mutableCopy];
NSDate *newDate = [[NSDate date] copy];
NSNumber *newNum = [[NSNumber numberWithInt:0] copy];
int n = [cards count];
for (int i = 0; i < n; i++)
{
Card *c = (Card *)[cards objectAtIndex:i];
// attempting to solve bug below
//NSLog(@"Setting card #%d", i); // if this line is uncommented, bug doesn't appear.
// bug!!!!! sometimes EXC_BAD_ACCESS
[c setNum_rep:newNum]; …Run Code Online (Sandbox Code Playgroud)