这是我现在正在使用的代码,但仍然出现各种错误:
No visible @interface for 'HomeViewController' declares the selector 'getCount'
和
/Volumes/Lex/HomeViewController.h:12:12: Required for direct or indirect protocol 'UIPickerViewDataSource'
/Volumes/Lexar/HomeViewController.m:15:17: Incomplete implementation
我的代码(.m 文件)
- (void)viewDidLoad
{
[super viewDidLoad];
PFUser *currentUser = [PFUser currentUser];
if (currentUser) {
NSLog(@"Current user: %@" , currentUser.username);
}
else {
[self performSegueWithIdentifier:@"showLogin" sender:self];
self.pickerView.dataSource = self;
self.pickerView.delegate = self;
}
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent: (NSInteger)component
{
if ([self getCount] == 0)
return 1;
return [self getCount];
}
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent: (NSInteger)component reusingView:(UIView *)view {
if ([self getCount] == 0)
return nil;
}
- (IBAction)logout:(id)sender {
[PFUser logOut];
[self performSegueWithIdentifier:@"showLogin" sender:self];
}
@end
和标题
/// .h controller
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface HomeViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate>
@property (strong, nonatomic) IBOutlet UIPickerView *pickerView;
- (IBAction)logout:(id)sender;
@end