【发布时间】:2010-02-25 22:32:53
【问题描述】:
我已经查看了有关此错误的所有先前问题和答案,但我无法弄清楚我做错了什么。有人可以帮忙吗?
@synthesize myScrollView;
@synthesize mathsPracticeTextArray;
-(void)loadText
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *textFilePath = [bundle pathForResource:@"mathspractice" ofType:@"txt"];
NSString *fileContents = [NSString stringWithContentsOfFile:textFilePath];
mathsPracticeTextArray = fileContents;
}
- (void)viewDidLoad {
[super viewDidLoad];
myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
myScrollView.contentSize = CGSizeMake(320, 960);
myScrollView.pagingEnabled = FALSE;
myScrollView.scrollEnabled = TRUE;
myScrollView.backgroundColor = [UIColor whiteColor];
*[self.view addSubview:myScrollView];
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,100,960,40)];
myLabel.text = [mathsPracticeTextArray componentsJoinedByString:@" "];
[myScrollView addSubview:myLabel];
[myLabel release];*
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
}
- (void)dealloc {
[myScrollView release];
[mathsPracticeTextArray release];
[super dealloc];
}
@end
【问题讨论】:
-
能把调试器的日志放上来吗?
-
我从调试器得到的只是“会话开始”,它实际上编译得很好,只是一个警告,但它没有显示我来自 mathspractice.txt 的文本
-
在IB中需要标签吗?
-
@Charles:告诉我们哪一行导致了警告,以及所有变量的声明类型如何?目前
myScrollView和mathsPracticeTextArray的类型没有指定。 -
@Charles Marsh:标签不能包含空格,所以写
objective-c而不是objective c。由于objective-c在他们感兴趣的标签列表中,这将确保更多的人会看到您的问题。
标签: objective-c nsarray compiler-warnings