How to reload a tableView i.e call the viewDidLoad method if a condition is met
- by Kquane Ingram
The problem is this i need a way to basically erase all the entry data a user placed into my arrays if a condition is met. Im new to Objective-C and iOS programming, but i believed the solution might be in calling the viewDidLoad method, thus it would virtually refresh the applications with the values of the array reset to default. If there is any other logical way of doing this i would appreciate the help.
In short i need to refresh the arrays as they were when the application first launched and the user did not select anything.
This is the part where i need it to refresh.
if ([gradeRecieved objectAtIndex:i]==nil) {
break; // if this condition is met the program must begin anew.
Edit* I need to recall the - (void)viewDidLoad method
here is more of the code.
-(IBAction)button:(id)sender{
int i = 0;
int sum = 0;
int gradeEarned;
int creditHours = 3;
for ( i=0;i<8 ; i++) {
if ([[points objectAtIndex:i] tag]==GradeA.intValue) {
[gradeRecieved replaceObjectAtIndex:i withObject:GradeA];
}
if ([[points objectAtIndex:i]tag]==GradeB.intValue) {
[gradeRecieved replaceObjectAtIndex:i withObject:GradeB];
}
if ([[points objectAtIndex:i]tag]==GradeC.intValue){
[gradeRecieved replaceObjectAtIndex:i withObject:GradeC];
}
if ([gradeRecieved objectAtIndex:i]==nil) {
break; // if this condition is met the program must restart.
}
}
while ( i<[gradeRecieved count]) {
if ([gradeRecieved objectAtIndex:i] == GradeA ) {
[finArray replaceObjectAtIndex:i withObject:GradeA];
i++;
continue;
}
if ([gradeRecieved objectAtIndex:i] == GradeB ) {
[gradeRecieved replaceObjectAtIndex:i withObject:GradeB];
i++;
continue;
}
if ([gradeRecieved objectAtIndex:i] == GradeC ) {
[gradeRecieved replaceObjectAtIndex:i withObject:GradeC];
i++;
continue;
}
}