Skip to content
Snippets Groups Projects
Commit ce54b7d4 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

even simpler

parent ab83d915
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
@interface AppDelegate : UIResponder <UIApplicationDelegate>{ @interface AppDelegate : UIResponder <UIApplicationDelegate>{
@public @public
bool compute; bool compute;
NSMutableArray *errors;
} }
@property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) UIWindow *window;
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
self.splitViewController = [storyboard instantiateViewControllerWithIdentifier:@"SplitViewController"]; self.splitViewController = [storyboard instantiateViewControllerWithIdentifier:@"SplitViewController"];
} }
compute = false; compute = false;
errors = [[NSMutableArray alloc] init];
// Copy resource files if the version of the app has changed // Copy resource files if the version of the app has changed
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *prefsv = [prefs stringForKey:@"OnelabModelsVersion"]; NSString *prefsv = [prefs stringForKey:@"OnelabModelsVersion"];
......
...@@ -76,12 +76,6 @@ ...@@ -76,12 +76,6 @@
//[_loadingAlert release]; //[_loadingAlert release];
_loadingAlert = nil; _loadingAlert = nil;
} }
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
if(appDelegate->errors.count > 0){
_errorAlert = [[UIErrorAlertView alloc] initWithTitle:@"Error" message:[appDelegate->errors firstObject] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil];
[_errorAlert show];
}
} }
- (void)viewDidLoad - (void)viewDidLoad
...@@ -182,11 +176,6 @@ ...@@ -182,11 +176,6 @@
[_progressLabel setHidden:YES]; [_progressLabel setHidden:YES];
[_progressIndicator stopAnimating]; [_progressIndicator stopAnimating];
[_progressIndicator setHidden:YES]; [_progressIndicator setHidden:YES];
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
if(appDelegate->errors.count > 0){
_errorAlert = [[UIErrorAlertView alloc] initWithTitle:@"Error" message:[appDelegate->errors firstObject] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil];
[_errorAlert show];
}
} }
- (void)stop - (void)stop
...@@ -310,26 +299,6 @@ ...@@ -310,26 +299,6 @@
return YES; return YES;
} }
#pragma mark - Alert view
-(void)addError:(std::string)msg
{
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
NSString *str = [Utils getStringFromCString:msg.c_str()];
// remove document path from error message
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docPath = [[paths objectAtIndex:0] stringByAppendingString:@"/"];
str = [str stringByReplacingOccurrencesOfString:docPath
withString:@""];
[appDelegate->errors addObject:str];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
[appDelegate->errors removeAllObjects];
}
#pragma mark - Split view #pragma mark - Split view
-(BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation -(BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
...@@ -347,8 +316,10 @@ void messageFromCpp (void *self, std::string level, std::string msg) ...@@ -347,8 +316,10 @@ void messageFromCpp (void *self, std::string level, std::string msg)
[(__bridge id) self performSelectorOnMainThread:@selector(setProgress:) [(__bridge id) self performSelectorOnMainThread:@selector(setProgress:)
withObject:[Utils getStringFromCString:msg.c_str()] waitUntilDone:YES]; withObject:[Utils getStringFromCString:msg.c_str()] waitUntilDone:YES];
} }
else if(level == "Error") else if(level == "Error"){
[(__bridge id)self addError:msg]; [(__bridge id) self performSelectorOnMainThread:@selector(showError:)
withObject:[Utils getStringFromCString:msg.c_str()] waitUntilDone:YES];
}
} }
-(void)setProgress:(NSString *)progress -(void)setProgress:(NSString *)progress
...@@ -356,6 +327,19 @@ void messageFromCpp (void *self, std::string level, std::string msg) ...@@ -356,6 +327,19 @@ void messageFromCpp (void *self, std::string level, std::string msg)
[_progressLabel setText:progress]; [_progressLabel setText:progress];
} }
-(void)showError:(NSString *)msg
{
// only show first error
if(_errorAlert != nil && _errorAlert.visible) return;
// remove document path from error message
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docPath = [[paths objectAtIndex:0] stringByAppendingString:@"/"];
NSString *str = [msg stringByReplacingOccurrencesOfString:docPath withString:@""];
_errorAlert = [[UIErrorAlertView alloc] initWithTitle:@"Error" message:str delegate:self
cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
[_errorAlert show];
}
-(void)handleProgressIndicatorTap:(id)sender -(void)handleProgressIndicatorTap:(id)sender
{ {
[_progressLabel setHidden:!_progressLabel.hidden]; [_progressLabel setHidden:!_progressLabel.hidden];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment