我遇到以下代码的两个问题。首先,当点击提交按钮时,应该运行userCategorySave Parse云功能,但是没有迹象表明它在我的日志中运行。
另一个问题是我收到的错误use of undeclared identifier 'prepareForSegue'
。我的印象是prepareForSegue
是iOS应用程序的标准部分,并且不需要声明。为什么这门课特别给我这个错误?
#import "CriteriaViewController.h"
@interface CriteriaViewController ()
@property (weak, nonatomic) IBOutlet UISegmentedControl *itemConditionSegment;
@property (weak, nonatomic) IBOutlet UISegmentedControl *itemLocationSegment;
@property (weak, nonatomic) IBOutlet UIButton *submitButton;
@end
@implementation CriteriaViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)itemConditionSegment:(id)sender{
UISegmentedControl *segmentedControl = (UISegmentedControl *) sender;
NSInteger selectedSegment = segmentedControl.selectedSegmentIndex;
if (selectedSegment == 0) {
self.itemCondition = @"new";
}
else{
self.itemCondition = @"any";
}
}
- (IBAction)itemLocationSegment:(id)sender {
UISegmentedControl *segmentedControl = (UISegmentedControl *) sender;
NSInteger selectedSegment = segmentedControl.selectedSegmentIndex;
if (selectedSegment == 0) {
self.itemLocation = @"US";
}
else if (selectedSegment == 1) {
self.itemLocation = @"WorldWide";
}
}
//add all the info to users respective new category object
- (IBAction)submitButton:(id)sender
{
if (self.minPrice.text.length > 0 && self.maxPrice.text.length > 0)
{
[PFCloud callFunctionInBackground:@"userCategorySave"
withParameters:@{@"categoryId": self.chosenCategory,
@"minPrice": self.minPrice.text,
@"maxPrice": self.maxPrice.text,
@"itemCondition": self.itemCondition,
@"itemLocation": self.itemLocation,}
block:^(NSString *result, NSError *error) {
if (!error) {
NSLog(@"Criteria successfuly saved.");
[self performSegueWithIdentifier:@"ShowMatchCenterSegue" sender:self];
}
}];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
@end
答案 0 :(得分:2)
您未正确关闭}
。请在上述方法prepare for seque
中添加一个。