-1
我們具有「喜歡,不喜歡和評論」功能。每當任何用戶點擊更多的時間點贊按鈕,它就會顯示Exc_Bad_Access [Code = 1]錯誤。以下是代碼中出現此錯誤的部分。在多個按鈕單擊時獲取不良異常錯誤
-(IBAction)sendLike:(id)sender{
UIButton *btn=(UIButton *)sender;
if(!btn.tag)
{
btn.tag=0;
}
postCell *curCell=(postCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:btn.tag inSection:0]];
user *myUser = [[[user alloc] init] autorelease];
if([myUser likeObjectByID:[[[self.thePosts objectAtIndex:[(UIButton *) sender tag]] theData] objectForKey:@"itemID"]]){
curCell.myASB.likeCount += 1;
curCell.myASB.canLike=YES;
[[[self.thePosts objectAtIndex:curCell.myIndex] theData] setObject:[NSString stringWithFormat:@"0"] forKey:@"canLike"];
NSString *tempCount = [NSString stringWithFormat:@"%i", curCell.myASB.likeCount];
[[[self.thePosts objectAtIndex:curCell.myIndex] theData] setObject:tempCount forKey:@"likes"];
[self.tableView reloadData];
}
}
安置自己在GitHub代碼第一或透露更多的細節,否則就沒有辦法瞭解你的情況 – Ducky
嘗試exclusiveTouch設置爲true – Venkat
嘗試更新項目中使用ARC。 – rmaddy