I'm trying to develop an iOS app , that allow the user to enter a word then press the button to get the definition of the word
Actually I have a file which contains the words and their definitions such that
Apple , the definition
orange , the definition
I wrote the code but I don't know why it's not working
#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
Can anyone help me to figure out what is wrong?