我正在尝试开发一个 iOS 应用程序,它允许用户输入一个单词然后按下按钮来获取单词的定义
实际上我有一个文件,其中包含单词及其定义,例如
Apple , the definition
orange , the definition
我写了代码,但我不知道为什么它不起作用
#import "ViewController.h"
NSString *readLineAsNSString(FILE *file);
@interface ViewController ()
@end
@implementation ViewController
@synthesize text;
@synthesize lab;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)butt:(id)sender {
FILE *file = fopen("1.txt", "r");
NSString *a = text.text ;
bool found =FALSE;
while(!feof(file)|| !found )
{
NSString *line = readLineAsNSString(file);
if ((a= [[line componentsSeparatedByString:@","] objectAtIndex:1])) {
lab.text = [[line componentsSeparatedByString:@","] objectAtIndex:0];
}
fclose(file);
}
}
@end
谁能帮我找出问题所在?