我正在关注“Sams教你自己iOS 6”,我尝试对此错误进行排除,但没有成功。
这是我的ViewController.h文件:
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UISegmentedControl *colorChoice;
@property (weak, nonatomic) IBOutlet UIWebView *flowerView;
@property (weak, nonatomic) IBOutlet UIWebView *flowerDetailView;
- (IBAction)toggleFlowerDetail:(id)sender;
- (IBAction)getFlower:(id)sender;
@end
我收到的错误是在ViewController.m文件中 [self.getFlower:nil]; ,
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.flowerDetailView.hidden=YES;
[self.getFlower:nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)toggleFlowerDetail:(id)sender {
self.flowerDetailView.hidden=! [sender isOn];
}
- (IBAction)getFlower:(id)sender {
NSURL *imageURL;
NSURL *detailURL;
NSString *imageURLString;
NSString *detailURLString;
NSString *color;
int sessionID;
color=[ self.colorChoice titleForSegmentAtIndex:self.colorChoice.selectedSegmentIndex];
sessionID=random() % 50000;
imageURLString=[[NSString alloc] initWithFormat: @"http://www.floraphotographs.com/showrandomios.php?color=%@&session=%d", color, sessionID];
detailURLString=[[NSString alloc] initWithFormat: @"http://floraphotographs.com/detailios.php?session=%d", sessionID];
imageURL=[[NSURL alloc]initWithString:imageURLString];
detailURL=[[NSURL alloc]initWithString:detailURLString];
[self.flowerView loadRequest: [NSURLRequest requestWithURL:imageURL]];
[self.flowerDetailView loadRequest:[NSURLRequest requestWithURL:detailURL]];
self.flowerDetailView.backgroundColor=[UIColor clearColor];
}
@end
方法getFlower已经在头文件中声明了,为什么我不能在实现文件中使用它呢?
答案 0 :(得分:4)
此:
[self.getFlower:nil];
应该是:
[self getFlower:nil];
这是一种方法,而不是财产。