我正在编写一个从文本字段中获取字符串的方法,并将其发送到Parse端的云代码函数。 Xcode给了我错误Use of undeclared identifier 'PFCloud'
,即使我在SearchViewController.h中导入了解析头。可能导致这种情况的原因是什么?
SearchViewController.m:
#import "SearchViewController.h"
@interface SearchViewController ()
@property (weak, nonatomic) IBOutlet UITextField *itemSearch;
@property (weak, nonatomic) IBOutlet UIButton *nextButton;
@end
@implementation SearchViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if (sender != self.nextButton) return;
if (self.itemSearch.text.length > 0) {
[PFCloud callFunctionInBackground:@"averageStars"
withParameters:@{@"item": self.itemSearch.text}
block:^(NSNumber *ratings, NSError *error) {
if (!error) {
// ratings is 4.5
}
}];
}
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
@end
SearchViewController.h:
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface SearchViewController : UIViewController
@end