Skip to content

Commit

Permalink
Merge pull request #160 from fbu-team-awesome/profile-crash-fix2
Browse files Browse the repository at this point in the history
Fixed bug that made app crash if current user didn't have relationships loaded.
  • Loading branch information
cbarrazaa1 committed Aug 10, 2018
2 parents e9adf7b + defba95 commit 209cb49
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions AppDelegate.m
Expand Up @@ -8,6 +8,7 @@

#import "AppDelegate.h"
#import "APIManager.h"
#import "PFUser+ExtendedUser.h"

@import GoogleMaps;
@import GooglePlaces;
Expand All @@ -24,9 +25,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[[APIManager shared] setupGoogle];

if (PFUser.currentUser) {

[[PFUser currentUser] retrieveRelationshipWithCompletion:^(Relationships *relationship) {
[PFUser currentUser].relationships = relationship;
}];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

self.window.rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"TabBarController"];
}

Expand Down
6 changes: 4 additions & 2 deletions View Controllers/LoginViewController.m
Expand Up @@ -49,8 +49,10 @@ - (IBAction)didTapLogin:(id)sender {
if (error != nil) {
[AlertHelper showAlertWithTitle:@"Login Error:" message:error.localizedDescription sender:self];
} else {
NSLog(@"User logged in successfully.");
[self performSegueWithIdentifier:@"loginSegue" sender:nil];
[[PFUser currentUser] retrieveRelationshipWithCompletion:^(Relationships *relationship) {
[PFUser currentUser].relationships = relationship;
[self performSegueWithIdentifier:@"loginSegue" sender:nil];
}];
}
}];
}
Expand Down
7 changes: 5 additions & 2 deletions View Controllers/SignUpViewController.m
Expand Up @@ -87,8 +87,11 @@ - (IBAction)confirmClicked:(id)sender {
if (error != nil) {
[AlertHelper showAlertWithTitle:@"Sign Up Error:" message:error.localizedDescription sender:self];
} else {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
[self presentViewController:[storyboard instantiateViewControllerWithIdentifier:@"TabBarController"] animated:YES completion:nil];
[[PFUser currentUser] retrieveRelationshipWithCompletion:^(Relationships *relationship) {
[PFUser currentUser].relationships = relationship;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
[self presentViewController:[storyboard instantiateViewControllerWithIdentifier:@"TabBarController"] animated:YES completion:nil];
}];
}
}];
}
Expand Down

0 comments on commit 209cb49

Please sign in to comment.