Searched User Profile
Instagram Firebase
Because we've built out a working UserProfileController that recognizes our current logged in user, we'll modify it's logic to retrieve information based on the searched user. Along the way, I'll show you guys a couple of bugs that we need to fix to ensure our application appears polished.

Comments (22)
eilufoye
6 years ago
THANK YOU! Brian. You are a blessing!
Hen Shabat
6 years ago
Hi Brian, How we can handle with left alignment for the searchBar placeholder? Thanks!
Brian Voong
6 years ago
yannsonnboys
6 years ago
Hey amazing video part 23. I was wondering if you can also integrate two other option? Like - people can post picture of video. - people can make a Hashtag (#). Those option will be great
Brian Voong
6 years ago
yannsonnboys
6 years ago
Hey Brian which lesson is that Game of Thrones? Is that the Chat lesson with Firebase?
Brian Voong
6 years ago
josephlausf
6 years ago
Holy crap that looks like another awesome course!
Fred van Rijswijk
6 years ago
Brian, I see strange warning " Unbalanced calls to begin/end appearance transitions for ... " if I go back from the UserProfile to the UserSearch... Code is the same by me and don't see it in your console ;-(
Slava Nagornyak
6 years ago
You are using Swift 3.1. Brian has a video on his YouTube channel about it. Long story short: you as well as all of us need to wait until Google updates it's Firebase to Swift 3.1. For now you just have to deal with it
Fred van Rijswijk
6 years ago
Sorry, my bad... just wasn't call a the right super on viedDidAppear.
faraz
6 years ago
Hi Brian. There seems to be a bug in my code, every time I load up my app and go to the user profile the posts do not appear on the profile. Is this something we are going to learn to take care of in the later lessons?
Brian Voong
6 years ago
faraz
6 years ago
Hey Brian, yes I downloaded that and I noticed that in the UserProfileController you had a different fetchUser function, I implemented that but I still get the error "Failed to fetch posts: Error Domain=com.firebase Code=1 "Permission Denied" in the console
faraz
6 years ago
UPDATE: Hey Brian, I actually copy and pasted the code from the source code and it seems to be working without the bug. Thanks for your help, your amazing!
Hen Shabat
6 years ago
Hi Brian, I noticed that if you go user from search and back ( for few times ) the screen is still alive. His reference dose not dismiss. Is it something with strong and weak? Regards, Hen
Brian Voong
6 years ago
Razzor Owa
6 years ago
Hey, Brian. I'd like to know how to dismiss the keyboard. I know that it's very simple but I tried a lot of ways and I don't get what I'm doing wrong.
Brian Voong
6 years ago
malrhex
4 years ago
calling it on the ViewDidLoad or in the closure UISearchBar?
Sharky011
6 years ago
Hi Brian, I made search bar like this, navigationItem.titleView = searchBar, and didnt have many of these problems. By the way excellent video, thanks.
Colin Clark
6 years ago
Great pace and explanation Brian! Interestingly enough I ran into an issue with Facebook's iOS App this morning where the keyboard wouldn't dismiss from one UI text field which led to it covering up the next date field UI scroll controller for selecting years. #evenzuckerbergshouldwatchLBTA
Drew Pasma
5 years ago
Love it #evenzuckerbergshouldwatchLBTA
nicsgodlike@gmail.com
5 years ago
Hi Brian, I know this is too much to ask but do you have any recommendation any references to read, watch for programming progmatically?. I really inspired of not using the storyboard. Doing everything in coding made me easy to understand how everything works. I just want to practice and learn more. If you got recommendation please reply. Or you can make a video tutorials I dont mind paying for it because I know it will be worth it. Thanks Senpai
Laurent Maquet
5 years ago
Hi brian, I used to write : for (key, value) in dictionaries Instead of... dictionaries.forEach( {key, value in... because I found this is easier to use... Is this exactly the same result ? Actually, I have now an issue with the first fix of this video : the "return" statement results in stopping the fetchUsers function. I suspect that the above mentioned syntax may be the cause of this issue ? Is this a matter of synchronous/asynchronous function ?
Brian Voong
5 years ago
Laurent Maquet
5 years ago
Thanks Brian. Understood... On the contrary, with "dictionaries.forEach({ ...", how to make sure that all iterations are done before going on ? In this case, is it better to use "for (key, value) in dictionaries" ?
Sieder Villareal
5 years ago
hey brian, i want to understand how the UserProfileController is being used. so basically this line let uid = userId ?? Auth.auth().currentUser?.uid ?? "" means, if i go to search controller and tap on a user, it will go to UserProfileController and call the fetchUser() function from viewDidLoad, thus it will be "userID" from the line above? and if I go directly to profile, its going to call Auth.auth().currentUser?.uid, do i understand it properly? Thanks
Brian Voong
5 years ago
Sieder Villareal
5 years ago
that was quick! thanks very much senpai!
p31d3ng
5 years ago
Hi Brian, I wonder why not just directly pass the user from UserSearchController to UserProfileController when the user clicked on a certain user? The selected user's info has been downloaded, why fetching it again? The code would be like this: - UserSearchController didSelectItemAt: userProfileController.user = user navigationController?.pushViewController(userProfileController, animated: true) - UserProfileController viewDidLoad(): if user == nil { fetchUser() } because user is just set, that's no need to download the user info from uid again right? Since it's not that clean to keep a user var and a userId var at the same time. If they go out of sync for some reason, it will create some unexpected trouble.
Brian Voong
5 years ago
p31d3ng
5 years ago
thanks for the quick reply! there are definitely some tradeoffs between simplicity/cleanness and performance/caching. And I think in the official Instagram app all user info is newly fetched everytime to get the most recent user status as you do here. The only potential pitfall I see is to maintain `userId` and `user` separately, since it's likely to be a bug for later developers who want to take over your code in the future.
chasekling
5 years ago
Hi Brian, I've started to notice that when I move from the search page to the home feed and scroll down quickly, all the photos get jumbled and the console spits out the following: Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60800009c8e0 'UISV-canvas-connection' V:[UIButton:0x7f8c9b03cb70]-(0)-| (active, names: '|':UIStackView:0x7f8c9b03de30 )> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. 2018-09-06 21:04:12.904816-0700 InstagramFirebase[9676:8297519] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. Is this a known bug? Or have I added constraints incorrectly?
drestaccz
5 years ago
hi Brian i follow this lesson to the T and i can't not get the userProfile to load when i click on the user from the search profiler... I download the source project and still can't figure it out...
drestaccz
5 years ago
Found the issue
petar7
4 years ago
what was the issue?
petar7
4 years ago
Nevermind , I fixed it I added Auth.auth().currentUser.uid in Database Extension and that caused the problem
Boula
4 years ago
Providing Optimal solution: Hello Brian, i wanna share my own optimal solution and you could give me right feedback on it: I removed collectionView.reloadData() from fetchUsers() then , i added: self.timer?.invalidate() self.timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(self.reloadCollectionView), userInfo: nil, repeats: false) and inside reloadCollectionView: i typed self.collectionView.reloadData() I do all of that to minimize the call of reloadData just if i have 1000 records in collectionView ..... is that optimal solution, Brian ?! Thanks...
Brian Voong
4 years ago
Connor Laganà
4 years ago
Brian, I keep getting an error "Permission Denied". Any fix for the Database rules in Firebase?
Brian Voong
4 years ago
malrhex
4 years ago
how to delete the users on firebase? i just deleted them from authtentication website, but I still have like repited users xD I think this is from the cache of the simulator or something?
malrhex
4 years ago
disregard. I forgot to clean the database /users/ on the website. haha thank you anyways. btw! I love how you teach! keep it up! and yeah! of course good stuff! haha! excelent!
Santa
4 years ago
Profile images are swapped around when using filtering, names are stable but images are not. Any solution?
Brian Voong
4 years ago
Santa
4 years ago
Thx Brian
malrhex
4 years ago
Brian, why does the searchUserController UIWindow goes black while just getting the snapshot from observeSingleEvent on this line 'Database.database().reference().child("users").observeSingleEvent(of: .value, with: { (snapshot) in' when accessing the controller from homefeed embeded as serchBar on the NavBar, so I open the controller like this: func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool { handleShowSearchVC() return false } @objc func handleShowSearchVC() { let s = UserSearchController(collectionViewLayout: UICollectionViewFlowLayout()) s.modalPresentationStyle = .overCurrentContext navigationController?.pushViewController(s, animated: true)
malrhex
4 years ago
hope you are kinda chuck norris bro! xD just If you have any clue! let me know I'll appreciate that a lot!
Brian Voong
4 years ago
malrhex
4 years ago
Yeah it must be the hierarchy because it don't know how to check that out. background is already set up. collectionView?.isOpaque = false collectionView?.backgroundColor = .mainTransparentVC()
Clint Larenz Nurse
4 years ago
Any reason why the tab bar disappears when I click on a searched users profile?
Clint Larenz Nurse
4 years ago
Another issue, when I click the options button after searching a user and clicking their profile. It ask me if I want to log out of the user I searched for. Any way to go about this? Thanks!
HELP & SUPPORT