Ios 使用委托方法的CustomCell使我的应用程序崩溃
我的应用程序使用parse.com,我创建了一个包含委托的自定义单元格 FFCustomCellWithImage.h:Ios 使用委托方法的CustomCell使我的应用程序崩溃,ios,uitableview,delegates,tableview,parse-platform,Ios,Uitableview,Delegates,Tableview,Parse Platform,我的应用程序使用parse.com,我创建了一个包含委托的自定义单元格 FFCustomCellWithImage.h: @ class FFCustomCellWithImage; @ protocol FFCustomCellWithImageDelegate <NSObject> - (Void) cellaImmagine: (FFCustomCellWithImage *) cellaImmagine userPressedGoPointButtonAction: (UI
@ class FFCustomCellWithImage;
@ protocol FFCustomCellWithImageDelegate <NSObject>
- (Void) cellaImmagine: (FFCustomCellWithImage *) cellaImmagine userPressedGoPointButtonAction: (UIButton *) goPointButton goPointObject: (PFObject *) goPointObject sender: (id) sender;
@ end
@ interface FFCustomCellWithImage: UITableViewCell
@ property (nonatomic, weak) id <FFCustomCellWithImageDelegate> delegate;
这是在有Tableview的类中实现的方法:
FFTimeline.m:
#import "FFTimeline.h"
#import "FFCustomCellTimelineSocial.h"
#import "FFCustomCellWithImage.h"
#import "FFQueryCostanti.h"
@interface FFTimeline ()
@property (nonatomic, strong) PFObject *PostDetails;
@end
-(void)cellaImmagine:(FFCustomCellWithImage *)cellaImmagine userPressedGoPointButtonAction:(UIButton *)goPointButton goPointObject:(PFObject *)goPointObject sender:(id)sender {
self.PostDetails = [self.ArrayforPost objectAtIndex:[sender tag]];
goPointObject = self.PostDetails;
[cellaImmagine setGoPointButtonStatus:NO];
BOOL GoPointAssigned = !goPointButton.selected;
[cellaImmagine setGoPointStatus:GoPointAssigned];
NSString *initialNumberButton = goPointButton.titleLabel.text;
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"it_IT"]];
NSNumber *numeroGoPointAssegnati = [formatter numberFromString:goPointButton.titleLabel.text];
if (GoPointAssigned) {
numeroGoPointAssegnati = [NSNumber numberWithInt:[numeroGoPointAssegnati intValue] +1];
[self SaveGoPointAssegnatiClass:sender];
}
else {
if ([numeroGoPointAssegnati intValue] > 0) {
numeroGoPointAssegnati = [NSNumber numberWithInt:[numeroGoPointAssegnati intValue] -1];
[self DeleteGoPointToPostClass:sender];
}
}
[goPointButton setTitle:[formatter stringFromNumber:numeroGoPointAssegnati] forState:UIControlStateNormal];
if (GoPointAssigned) {
[FFCustomCellWithImage assegnaGoPointPost:goPointObject block:^(BOOL succeeded, NSError *error) {
FFCustomCellWithImage *actualHeaderView = (FFCustomCellWithImage *)[self tableView:self.FFTableView viewForHeaderInSection:goPointButton.tag];
[actualHeaderView setGoPointButtonStatus:YES];
[actualHeaderView setGoPointStatus:succeeded];
if (!succeeded) {
[actualHeaderView.AddGoPoint setTitle:initialNumberButton forState:UIControlStateNormal];
}
}];
} else {
[FFCustomCellWithImage eliminaGoPointPost:goPointObject block:^(BOOL succeeded, NSError *error) {
FFCustomCellWithImage *actualHeaderView = (FFCustomCellWithImage *)[self tableView:self.FFTableView viewForHeaderInSection:goPointButton.tag];
[actualHeaderView setGoPointButtonStatus:YES];
[actualHeaderView setGoPointStatus:!succeeded];
if (!succeeded) {
[actualHeaderView.AddGoPoint setTitle:initialNumberButton forState:UIControlStateNormal];
}
}];
}
}
请发布错误消息好吗?当应用程序崩溃时,NSLog没有返回任何错误,但我添加了一个断点异常,并显示以下行-(void)cellaImmagine:(FFCustomCellWithImage*)cellaImmagine用户PressEdgoPointButtonAction:(UIButton*)goPointButton goPointObject:(PFObject*)goPointObject发送者:(id)发送方和下面的消息EXC_BAD_ACCESS(code=1,address=0x50497265)我不知道这是否是一个问题,但是您用大写字母“V”声明了方法“Void”,而您用小写字母V实现它。否。。。不是“什么问题。。。资本是译者的错。。。对不起…您在哪里设置代理?方案中是否启用了僵尸对象?
#import "FFTimeline.h"
#import "FFCustomCellTimelineSocial.h"
#import "FFCustomCellWithImage.h"
#import "FFQueryCostanti.h"
@interface FFTimeline ()
@property (nonatomic, strong) PFObject *PostDetails;
@end
-(void)cellaImmagine:(FFCustomCellWithImage *)cellaImmagine userPressedGoPointButtonAction:(UIButton *)goPointButton goPointObject:(PFObject *)goPointObject sender:(id)sender {
self.PostDetails = [self.ArrayforPost objectAtIndex:[sender tag]];
goPointObject = self.PostDetails;
[cellaImmagine setGoPointButtonStatus:NO];
BOOL GoPointAssigned = !goPointButton.selected;
[cellaImmagine setGoPointStatus:GoPointAssigned];
NSString *initialNumberButton = goPointButton.titleLabel.text;
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"it_IT"]];
NSNumber *numeroGoPointAssegnati = [formatter numberFromString:goPointButton.titleLabel.text];
if (GoPointAssigned) {
numeroGoPointAssegnati = [NSNumber numberWithInt:[numeroGoPointAssegnati intValue] +1];
[self SaveGoPointAssegnatiClass:sender];
}
else {
if ([numeroGoPointAssegnati intValue] > 0) {
numeroGoPointAssegnati = [NSNumber numberWithInt:[numeroGoPointAssegnati intValue] -1];
[self DeleteGoPointToPostClass:sender];
}
}
[goPointButton setTitle:[formatter stringFromNumber:numeroGoPointAssegnati] forState:UIControlStateNormal];
if (GoPointAssigned) {
[FFCustomCellWithImage assegnaGoPointPost:goPointObject block:^(BOOL succeeded, NSError *error) {
FFCustomCellWithImage *actualHeaderView = (FFCustomCellWithImage *)[self tableView:self.FFTableView viewForHeaderInSection:goPointButton.tag];
[actualHeaderView setGoPointButtonStatus:YES];
[actualHeaderView setGoPointStatus:succeeded];
if (!succeeded) {
[actualHeaderView.AddGoPoint setTitle:initialNumberButton forState:UIControlStateNormal];
}
}];
} else {
[FFCustomCellWithImage eliminaGoPointPost:goPointObject block:^(BOOL succeeded, NSError *error) {
FFCustomCellWithImage *actualHeaderView = (FFCustomCellWithImage *)[self tableView:self.FFTableView viewForHeaderInSection:goPointButton.tag];
[actualHeaderView setGoPointButtonStatus:YES];
[actualHeaderView setGoPointStatus:!succeeded];
if (!succeeded) {
[actualHeaderView.AddGoPoint setTitle:initialNumberButton forState:UIControlStateNormal];
}
}];
}
}