I am new to iPhone and i am creating an iPhone app in which i am using simple text file as my database.
In firstView i have four UIButtons. I have four different text file.
What i want is when i select button1 then data from file1.txt will be load same as when i select button2 , button3 and button4 , data from file2 ,file3 ,file4 will be load respectively.
Something like this :
if(categoryVC.Quiz1btn isSelected == YES){
NSBundle *bundle = [NSBundle mainBundle];
NSString *textFilePath = [bundle pathForResource:@"file1" ofType:@"txt"];
NSString *fileContents = [NSString stringWithContentsOfFile:textFilePath encoding:NSUTF8StringEncoding error:nil];
[NSString stringWithContentsOfFile:textFilePath encoding:NSUTF8StringEncoding error:nil];
NSArray *quizArray = [[NSArray alloc] initWithArray:[fileContents componentsSeparatedByString:@"\n"]];
self.theQuiz = quizArray;
}
but this is not working.
Any Help will be appreciated.
Thank you.
What you can do is to add an (NSString*) filename attribut in your second viewController and pass the name of the selected file button as following in the fisrt view controller :
}
and so one …
And in viewDidLoad function of the second view controller you add the following code :