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
Luke Terzich
5,193 PointsProblem with RIBBIT type APP - Friends Relations won't release on logout!
Hello, i have followed the Ribbit App EXACTLY as shown in the videos and then adapted it slightly but testing as i go!
Im having a problem which i cannot seem to fix.
- Say i login with User1
- Add 2 friends called User2 and User 3
Logout
Create New Account called User4
Login and View friends
my friends are then User2 and User3 for User4 and User1
Does this make sense? No matter which account i login with it is always the same friends
8 Answers
Fernando Claussen
9,324 PointsNever checked, I noticed that when I was creating a lot of users to test the scrolling thing that he mentions on the video.
Whenever I leave my main user that has 2 friends (user1 and user2) and login with, let's say, user10, the same friends show up, although user10 has no friends.
JUST FIGURED IT OUT
I feel kinda dumb, really...
I checked the code for the FriendsTableViewController.m and realized that it was getting the relations in the viewDidLoad method. That means it was only getting the relations 1 time. Get all that code from viewDidLoad and place it in viewWillAppear:animated and it should work. Everytime the friends viewcontroller will appear, it will get the new current user and the new relations.
Doing that, I found another possible bug. On the EditFriendsTableViewController.m it is querying ALL the users on the viewDidLoad method. But, what if while I'm using my app, anyone if the same app joins? I wouldn't be able to see it, unless I really close the app and open again.
I also grabbed that piece of code and placed in the viewWillAppear:animated of EditFriendsViewController.m
Hope I helped :D
Luke Terzich
5,193 PointsBump - Sorry guys this is frustrating me
Fernando Claussen
9,324 PointsI had the EXACT same problem. Maybe someone from staff or mod could help us.
OR, maybe it's a bug that will be fixed on the next sections? Don't know.
Luke Terzich
5,193 Pointshopefully, does yours load the users from whoever was last logged in?
or does it show the exact same users everytime?
Luke Terzich
5,193 PointsOh mate you are a life saver! I also noticed the possible bug swell, never got round to doing it but you just reminded me thank you so much!! However, when i make a NEW user (and login for the first time) the data for whoever was last logged in is still their, very weird.....
Fernando Claussen
9,324 PointsCheck your InboxViewController ViewDidLoad method.
I took everything from there and placed inside the viewWillAppear method. Except for the self.moviePlayer allocation and initialization.
Luke Terzich
5,193 Pointsabsolutely perfect cheers pal such a big help, this is why i love FORUMS haha !!!!
chitra iyer
3,722 PointsI had this same problem when I was showing (off) my app. And I too put it in the viewWillAppear method. Found this today. Thanks for validating! However what happens when you have more complex code in viewDidLoad and do not want to call it every time the view appears say, like database query for a huge master set? A better idea would be to unload all views on logout so that they are loaded fresh for every login. I looked up and could not find a straightforward solution. Has anyone tried this?