Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Trent Burkenpas
Trent Burkenpas
22,388 Points

Here we go again! The Ribbit app

soooooo...Im setting up the logging in and out for the Ribbit app. I have 2 Problems. When I log in and then end the simulator, then run it again, I have to sign in again. But it should stya logged in for me until I log out. another issue is when i do log in i get this error message

Ribbit[9500] <Error>: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

This Ribbit app is going to be the death of me!

Thankfs for the help!

4 Answers

Stone Preston
Stone Preston
42,016 Points

here is your issue:

 PFUser *currentUser = [PFUser currentUser];
    if (currentUser) {
        NSLog(@"Current user: %@", currentUser.username);
    }
    else {
        [self performSegueWithIdentifier:@"showLogin" sender:self];
    }

    //this line runs no matter what, even if the user is already logged in. You dont want this
    [self performSegueWithIdentifier:@"showLogin" sender:self];

notice how in your else block you perform the showLogin segue, then after that else block your perform the showLogin segue regardless if the user is logged in or not? Basically the if/else block runs, then no matter what the showLogin segue is performed. Try removing that last line so you have

 PFUser *currentUser = [PFUser currentUser];
    if (currentUser) {
        NSLog(@"Current user: %@", currentUser.username);
    }
    else {
        [self performSegueWithIdentifier:@"showLogin" sender:self];
    }
Stone Preston
Stone Preston
42,016 Points

in regards to the CGContext error, i got that as well, and from what I could find on stack overflow its a bug with ios 7/several ios 7 controls. You can just google the error and find several posts about it. here is one of the posts im referencing

your right about the sign in. You should only have to sign in once. Please post the code for your inbox view controller, specifically your view did load method where you check to see if a user is signed in.

Trent Burkenpas
Trent Burkenpas
22,388 Points

OK thank you !

- (void)viewDidLoad
{
    [super viewDidLoad];


    PFUser *currentUser = [PFUser currentUser];
    if (currentUser) {
        NSLog(@"Current user: %@", currentUser.username);
    }
    else {
        [self performSegueWithIdentifier:@"showLogin" sender:self];
    }
    [self performSegueWithIdentifier:@"showLogin" sender:self];


}