问:这是我的直接代码,我不知道为什么在尝试构建时为什么不成功,如果您能告诉我什么字符是错误的,那将非常有帮助!
//
// ViewController.m
// CrystalBall
//
//由所有者在12/25/12创建。
//版权所有(c)2012 com.toptechnow。版权所有。
//
#进口“ViewController.h”
@interface的ViewController()
@end
@implementation的ViewController
@synthesize PredictionLabel;
-(void)viewDidLoad
{
[super viewDidLoad];
projectionArray = [[NSArray alloc] initWithObjects:@“确定”,“确定如此”,@“所有符号都说是”,
@“星星未对齐”
@“我的答复是否”,
@“
@“现在最好不要告诉你”,
@“集中注意力再询问”,
@“现在无法回答”,无];
}
-(void)viewDidUnload
{
[self setPredictionLabel:nil];
[super viewDidUnload];
//释放主视图的所有保留子视图。
}
-(BOOL)应该AutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//对于支持的方向返回是Yes
(interfaceOrientation!= UIInterfaceOrientationPortraitUpsideDown);
}
-(IBAction)ButtonPressed:(UIButton *)sender {
self.PredictionLabel.text = [predictionArray objectAtIndex:3];
}
@end
答:如果您复制并粘贴xCode显示的错误,这将非常有帮助。
这行在这里:
projectionArray = [[NSArray ...
改为:
self.predictionArray = [[NSArray ...
因为此属性属于ViewController的实现,所以我们将其指定为“ self”。
在这一行:
“绝对如此”
您忘记添加“ @”符号,如下所示:
@“绝对如此”
在此行中:
self.PredictionLabel.text = [predictionArray objectAtIndex:3];
您编写的是“ PredictionLabel”,而不是“ predictionLabel”。区别在于首字母不应大写。另外,它不是“ predictionArray”,而是“ self.predictionArray”。结果:
self.predictionLabel.text = [self.predictionArray objectAtIndex:3];
这些是我在代码中只能看到的唯一错误,但是我想我可能已经错过了其中一些错误。我只是一个初学者,如果对Objective-C有更多经验的人可以提供帮助,那将是非常不错的。