gpt4 book ai didi

ios - 获取 : Property 'getFlower' not found on object of type 'ViewController *'

转载 作者:行者123 更新时间:2023-11-28 19:02:51 24 4
gpt4 key购买 nike

我正在关注“Sams Teach Yourself 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方法已经在头文件中声明了,为什么不能在实现文件中使用呢?

最佳答案

这个:

[self.getFlower:nil];

应该是:

[self getFlower:nil];

这是一个方法,而不是一个属性。

关于ios - 获取 : Property 'getFlower' not found on object of type 'ViewController *' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23258285/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com