Apologies
You must be signed in to watch this lesson.
User Profile Image View
Instagram Firebase
In this lesson, we'll log the user back in using the credentials we originally created in the first couple of episodes. In order to do so, we'll create a separate login screen that only contains two input UITextFields. To login this user, we will be calling Sign In instead of the create user method. Let's also go over a simple way to check for when the key is pressed and used that as a signal to login our user.

Comments (57)
johnrm9
7 years ago
This is how I checked for the "OK" http response status code guard let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 else { print(response.debugDescription); return } //perhaps check for response status of 200 (HTTP OK)
Jesus Adolfo
7 years ago
aghh I am stuck... I did everything until minute 4:30 but unlike you, my collectionViewController is not even trying to render header. No error, nothing. What could I be missing, I can not tell ?
Brian Voong
7 years ago
Jesus Adolfo
7 years ago
I am still trying to figure this one out... I even downloaded the project to compare the code but can not find any difference. I tried to put break points on the following methods, however they're not even being called ` override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerId", for: indexPath) as UICollectionReusableView header.backgroundColor = .green return header } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { return CGSize(width: view.frame.width, height: 200) } `
Jesus Adolfo
7 years ago
nevermind... took me really long to figure this one out but I was initializing the collection view in the wrong way. I was doing: let layout = UICollectionViewLayout() let userProfileController = UserProfileController(collectionViewLayout: layout) isntead of: let layout = UICollectionViewFlowLayout() let userProfileController = UserProfileController(collectionViewLayout: layout) wow that took way too much time to figure out
Brian Voong
7 years ago
Barış Ç
6 years ago
problem is func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { return CGSize(width: view.frame.width, height: 200) } change this method: func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { return CGSize(width: view.frame.width, height: 200) }
edison1
6 years ago
you just saved my biggest headache at the moment!! It was something sooo small. code..
omari
7 years ago
Hello Brian, going back to the mainThread and setting the userprofileImage takes over 15 seconds :O . I tried it over 20 times it always took so much time. DispatchQueue.main.async { self.profileImageView.image = image } }.resume() My image just has 6.3 kb. My code has no bugs. I checked my code with breakpoints and the resume call takes a long time. Why is it like that and what can I do instead ? Thanks
omari
7 years ago
I still have these warnings. This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes. Stack:(
omari
7 years ago
Solved it :)
alpertabak
7 years ago
What was your solution? My username and profile image is lagging about 3-5 seconds
omari
7 years ago
Hello Brian, you created a top and a bottomDividerView and anchor it at the top and at the bottom of the stack view. Is it also possible to create vertical lines between the labels inside the stack view ? I tried it but could not create them.
Brian Voong
7 years ago
Dan Boyle
7 years ago
Hey Brian... So when you do a URLSession you are automatically going into a background thread correct? And to modify the UI you need to get back on the main thread... Anytime you access the Firebase database to grab a user like we did with the username in the nav controller title... why isn't that done in the background thread?
Brian Voong
7 years ago
Stephen Novotny
7 years ago
Brian I really like the way you structure your projects, fetching data into classes/structs and the MVC pattern. This could be emphasised even more (and earlier) imo. I did your twitter series which I thought was excellent in that regard and Im sure that this will pan out in a similar fashion. Have a good break
Stephen Novotny
7 years ago
Brian As a total ios noob I appreciate you covering URLSession here, but Im left wondering you didnt use the firebase methods like: // from Firebase docs https://firebase.google.com/docs/storage/ios/download-files let islandRef = storageRef.child("images/island.jpg") // Download in memory with a maximum allowed size of 1MB (1 * 1024 * 1024 bytes) islandRef.data(withMaxSize: 1 * 1024 * 1024) { data, error in if let error = error { // Uh-oh, an error occurred! } else { // Data for "images/island.jpg" is returned let image = UIImage(data: data!) } } Is it for the reason of teaching URLSession and another way to fetch an image or do you believe performance or simplicity via URLSession is more beneficial?
Brian Voong
7 years ago
Sid
7 years ago
If anybody experienced the same situation, please shine a light. Simply set “header.user = user” in the “dequeueReusableSupplementaryView” method does not work for me. “user” in the “UserProfileHeader” file is still nil. What I had to do is define var user: User? var header: UserProfileHeader? in the global scope and then do this self.user = User(dictionary: dictionary) self.header.user = self.user in the “fetchUser” method for it to work.
rinconchris
6 years ago
'header.user' is set in the viewForSupplementaryElementOfKind before the user is actually set in the UserProfileController (so it is nil). Check to make sure you have the 'self.collectionView?.reloadData()' in the fetchUser function after the user has been set for the controller - this will cause header.user to be set again. I had exact same issue and had to use a couple breakpoints to figure out what was going on.
Sid
6 years ago
This is exactly the cause, thank you.
ottogutierrez
6 years ago
hi rinconchris, I have the print statement on the didSet block. First I get a nil, and then I get the user data. Is this normal? Thanks,
Nick Perkins
7 years ago
For some reason, I still have a red circle. This piece of code below doesn't even fire in URLSession. Not sure what I missed. I double checked your code Brian with mine and I'm still stumped. DispatchQueue.main.async { self.profileImageView.image = image }
Nick Perkins
7 years ago
Nevermind Brian. Found my problem in ViewController let dictionaryValues = ["username": username, "profileImageURL": profileImageUrl] profileImageURL should be Url. *eye roll*
camlinares@gmail.com
6 years ago
Brian, Great course, your video lessons have been great to use. Quickly, I am currently encountering an error after implementing the struct User object. My view controller is returning an error which reads "Cannot convert value type of "(User?, Error?) -> ()" to expected argument. Have you encountered this? If so, do you have a fix? Thanks!
Brian Voong
6 years ago
bokafor90
6 years ago
This is happening in func handleSignUp(). It is making the error for this line: Auth.auth().createUser(withEmail: email, password: password, completion: { (user: User?, error: Error?) in Let me know if anyone found a solution to this.
bokafor90
6 years ago
Also on your code you have 'FIRUser' but the new firebase update is 'User'
Brian Voong
6 years ago
bokafor90
6 years ago
It's me again... I solved the problem using this link here: https://firebase.google.com/docs/auth/ios/password-auth#create_a_password-based_account Auth.auth().createUser(withEmail: email, password: password) { (user, error) in Above is the new way of creating a user in Firebase. You may want to remove a '(' at the end of your code if you are changing Brian's code to the updated code. =)
Brian Voong
6 years ago
Brian Voong
6 years ago
bokafor90
6 years ago
No, Thank you for the quick response! Keep up the good work. Money well spent!!
jacquesj
6 years ago
Thank you very much, this solved the problem for me
mattnet
6 years ago
This issue is hanging me up too. I've updated to the latest Firebase cocoa pods, latest xCode and still not working for me. It was working last week, but can;t get this sessions code changes to run. Am i missing something clever to solve this? I've googled it to no avail....
mattnet
6 years ago
Scratch my last response on this....I was able to get it sorted by going back to the Firebase docs....looks like new syntax added a ')' after the password...to separate completion out into it's own AuthResultsCallback...
mattnet
6 years ago
Great lesson!
digimarktech
6 years ago
good stuff!
wasim
6 years ago
Brain, The green header is not appeared on in UICollectionView, and this my code: import UIKit import Firebase class UserProfileViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout { override func viewDidLoad() { super.viewDidLoad() collectionView?.backgroundColor = .white self.collectionView?.register(UICollectionViewCell.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "headerId") fetchUser() } override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerId", for: indexPath) header.backgroundColor = .green return header } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { return CGSize(width: view.frame.width, height: 200) } func fetchUser() { guard let uid = FIRAuth.auth()?.currentUser?.uid else {return} FIRDatabase.database().reference().child("users").child(uid).observeSingleEvent(of: .value, with: {(snapshot) in print(snapshot.value ?? "") guard let dictenary = snapshot.value as? [String: Any] else {return} guard let username = dictenary["username"] as? String else {return} self.navigationItem.title = username }){(error) in print(error) } } } please can help
luccaccine
6 years ago
Make sure that you are using 'UICollectionViewFlowLayout' instead 'UICollectionViewLayout' in construtor where you instantiates your UserProfileViewController class. If your files is according to Brian files, check inside: MainTabController.swift the line: let layout = UICollectionViewFlowLayout()
annajorrman
6 years ago
I'm having the same isuue
José Luis Cornejo
6 years ago
It is right! Thank's luccaccine
Ari Bozhani
6 years ago
I am getting an error saying that I cannot convert value of type '(User?, Error?) -> () to expected argument in my view controller file. This happened after I completed the code in this section of the tutorial. Any advice please?
luccaccine
6 years ago
It's because you created a struct called User, and it conflits with the Firebase User model. You have 2 options to fix that. 1) Change your User struct to other name, like UserApp, etc... 2) Refers to the Firebase User like that: Firebase.User? So your line would be: Auth.auth().createUser(withEmail: email, password: password) { (user: Firebase.User?, error: Error?) in I prefer the last one.
Ari Bozhani
6 years ago
Hi Luccaccine, Thank you. I chose the second option and it worked! Thank you! Ari
smiller193
6 years ago
Is anyone having an issue with the input accessory view getting stuck at the bottom? When exiting comment screen
stonypig1
6 years ago
could you tell me how to implement a tableview header in code? it is similar to this or if not, is there any article about it? thanks
Brian Voong
6 years ago
stonypig1
6 years ago
thank you
nooraldoori
6 years ago
I get this err can any one help me please " libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) "
Brian Voong
6 years ago
Mamun Simul
6 years ago
May be one of your variables turn out to be nil during execution.
angeloCEO
6 years ago
since I download the new Xcode 9 I automatically run to a lot of problems​.
Adam El-Kadi
6 years ago
Hey Brian can I please send you my file, can you please look at it and tell me what could have possibly been wrong.
Adam El-Kadi
6 years ago
Even your project file doesn't run it
Adam El-Kadi
6 years ago
Nvm Brian, I got it turns out the problem was that my user didn't have a user picture :P Thanks anyway
mattphelps
6 years ago
Hi Brian, The simulator is just black. Even when I download your project files, import firebase, it still does not run any of the code of the last few lessons. Don't know what to do. Thanks - Matt
mattphelps
6 years ago
Or rather, profile image or userrname is not displayed. Despite having created users
Brian Voong
6 years ago
mattphelps
6 years ago
Thank you Brian, your punctual reply is appreciated.
David Wu
6 years ago
The name of the struct "User" is the same as the firebase User class, which causes the problem in "handleSignUp"
Brian Voong
6 years ago
David Wu
6 years ago
Thanks so much for your prompt reply. So what we need is just to put "FirebaseAuth" in front of the "User" in handleSignUp call?
Brian Voong
6 years ago
David Wu
6 years ago
Thanks a lot for the clear explanation. This is so helpful! Have a wonderful thanksgiving!!
Tokyojogo
6 years ago
Hi Brian, I'm just 1/3 in this video... I can't seem to display the profileImageView. I did exactly in your vid and the blue header is displaying but the profileImageView doesn't display and I am at a loss. I did it a couple of times already, restarted the simulator and the project but its not displaying... and idea?
Tokyojogo
6 years ago
Nevermind. Solved it. Had an error with the anchor....
Polas Opel
6 years ago
Hey I wanted to set the cornerRadius like = profileImageView.frame.Width/2 instead of 80/2, why doesn't that work as well? When you set it like that, it doesn't get round.
Brian Voong
6 years ago
rehan1531
6 years ago
what .resumeI() do and why we call it ?
rehan1531
6 years ago
Hey Brian , What does .resume() function does ?
Brian Voong
6 years ago
rehan1531
6 years ago
wow awesome explanations :-) : -) :-)
dubbasar
6 years ago
Hey Brian, You have used struct for the User. My question is what if we used Class instead of structures. I know that Class is reference type and struct is a value type. But whats the main reason behind the use of struct here. Is that struct don't create unnecessary references and safe to reside its copy in memory? Thanks in advance
Shahrukh Mohammad
6 years ago
Hi Brian, Hope you're well and your courses are honestly one of the best around (a lot better than udemy). I have an annoying question though: I'm trying to implement the ability for user to change his profile picture by replacing the UIImageView with a UIButton and using the same imagePicker functionality you did for the login page. However since I'm trying to achieve this within the userHeader class and not a UIViewController class, I cannot get the imagePickerController to appear using "present". Is there a way to achieve this in a class that's not a ViewController class? I hope it made sense and maybe you can shine some light upon it if it's not too much trouble. Thanks once again.
Brian Voong
6 years ago
Pren22
6 years ago
Hey Brian, When trying to get the image to show up in the profileImageView nothing shows up both ways. I also tried to print the data but it showed nothing in my console.
Brian Voong
6 years ago
Pren22
6 years ago
Never mind, I figured it out lol, it was such a small thing that was wrong!
3lombe
6 years ago
At 9:40 my profileImageView is not showing up at all. Everything has been working fine up to this point. Now I'm just trying to tackle this problem. I'll do some more troubleshooting on my own but in the meantime, any suggestions would be much appreciated.
3lombe
6 years ago
nvm, missed a few steps in previous lessons
frankcrest
5 years ago
which part?
jayrsonani
6 years ago
hey brian profile pitur not show in profile header ? so please help me
jayrsonani
6 years ago
hey Brian how to set center in profileimageview? profileImageView.anchor(top: topAnchor, left: leftAnchor, bottom: nil, right: nil, paddingTop: 12, paddingLeft:100 , paddingBottom: 150, paddingRight: 100, width: 80, height: 80) check the constraints please fast reply..
Brian Voong
6 years ago
jayrsonani
6 years ago
profileImageView.anchor(top: topAnchor, left: leftAnchor, bottom: nil, right: nil, paddingTop: 12, paddingLeft:100 , paddingBottom: 150, paddingRight: 100, width: 80, height: 80) where use this centerXAnchor,centerYAnchor please help me out this problem..
jayrsonani
6 years ago
profileImageView.anchor(top: topAnchor, left: leftAnchor, bottom: nil, right: nil, paddingTop: 12, paddingLeft:100 , paddingBottom: 150, paddingRight: 100, width: 80, height: 80) where use this centerXAnchor,centerYAnchor please help me out this problem.. please fast
Brian Voong
6 years ago
jayrsonani
6 years ago
ok i will try this
jayrsonani
6 years ago
profileImageView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true xcode error is = Use of unresolved identifire 'view' so what i do brian. please solved this error thanks advance
jayrsonani
6 years ago
hey brian i cant show image in profile image view how to solved this please fix it fileprivate func setupProfileImage() { guard let profileImageUrl = user?.profileImageUrl else { return } guard let url = URL(string: profileImageUrl) else { return } URLSession.shared.dataTask(with: url) { (data, response, err) in //check for the error, then construct the image using data if let err = err { print("Failed to fetch profile image:", err) return } //perhaps check for response status of 200 (HTTP OK) guard let data = data else { return } let image = UIImage(data: data) //need to get back onto the main UI thread DispatchQueue.main.async { self.profileImageView.image = image } }.resume() }
Brian Voong
6 years ago
jayrsonani
6 years ago
ok i will try show me your url means give me your url
DerekRM
6 years ago
Hello everyone I erased from firebase database the last test profile I made. Is there any way to create a new one at this stage or to set the program to not look for test3 and instead look for test2.. I am getting some errors and I am not sure if it is from my deleting the test3 profile using the X in the firebase program. thx
Talia
6 years ago
Hi,Brian你好 求助!!!不确定是不是因为版本不同的原因,代码出现错误,我把user和User改成了users和Users。但是后面还是出现了两处错误无法执行: var users: Users? { didSet { setupProfileImage(). //错误1:Use of unresolved identifier 'setupProfileImage' } fileprivate func setupProfileImage() { //错误2:Expected 'get', 'set', 'willSet', or 'didSet' keyword to start an accessor definition print("Did set \(users?.username)") guard let profileImageUrl = users?.profileImageUrl else { return } guard let url = URL(string: profileImageUrl) else { return } URLSession.shared.dataTask(with: url) { (data, response, err) in //check for the error,then construct the image using data if let err = err { print("Failed to fetch profile image:", err) return }。。。
p31d3ng
5 years ago
didSet少了个ending curly brace. 所以后面的所有method都会是认为在users里面. 补上就好了
christiaan2211
6 years ago
Hi there Guys, I'm noticing a small bug in my application at this point. Everytime I open up the app it first shows the UID for a second or so, before switching to the username that I want to be displayed. Is there a way to make the app 'forget' we asked for the UID to be displayed there in the first place, and just immidiately always show the username? Regards, Chris
Dennisvm82
5 years ago
Remove the following from viewDidLoad() in UserProfileController.swift to get rid of the temporary id. This call shouldn't be made twice, since it's already set in fetchUser(). "navigationItem.title = Auth.auth().currentUser?.uid"
ioskev
5 years ago
My header for some reason isn't showing, can someone tell me if theres anything wrong in my code? override func viewDidLoad() { super.viewDidLoad() navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Logout", style: .plain, target: self, action: #selector(handleLogout)) collectionView?.backgroundColor = .blue fetchUsers() collectionView?.register(UserProfileHeader.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "headerID") } override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerID", for: indexPath) return header } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { return CGSize(width: view.frame.width, height: 200) }
becandle
5 years ago
Change your layout in MainTabBarController let layout = UICollectionViewLayout() to let layout = UICollectionViewFlowLayout()
c0d3p03t
5 years ago
Boom, nice. I must have missed that somewhere when he specified it in the video. Showing nicely now, thanks!
Binary_Jackson
5 years ago
Worked for me. Thank you.
Devmountain18
5 years ago
Hey Brian, I could not fetch username, users profile for some reason, I follow along with all the steps. Please help me check if I miss something. Thank you /Users/thaodoan/Desktop/Screen Shot 2018-06-27 at 1.07.28 PM.png/Users/thaodoan/Desktop/Screen Shot 2018-06-27 at 1.06.56 PM.png/Users/thaodoan/Desktop/Screen Shot 2018-06-27 at 1.00.27 PM.png
Devmountain18
5 years ago
I can't send you screenshots. There is code: fileprivate func setUpFileImage(){ // guard let uid = Auth.auth().currentUser?.uid else {return} // Database.database().reference().child("users").child(uid).observeSingleEvent(of: .value, with: { (snapShot) in // print(snapShot.value ?? "") // guard let dictionary = snapShot.value as? [String: Any] else {return} // guard let profileImageUrl = dictionary["profileImageUrl"] as? String else {return} guard let profileImageUrl = user?.profileImageUrl else { return } guard let url = URL(string: profileImageUrl) else {return} URLSession.shared.dataTask(with: url) { (data, response, err) in if let err = err { print("Failed to fetch profile image", err) } guard let data = data else {return} let image = UIImage(data: data) DispatchQueue.main.async { self.profileImageView.image = image print(data) } }.resume() // }) { (error) in // print("Failed to fetch user", error) // } } Fetch userName: fileprivate func fetchUser() { guard let uid = Auth.auth().currentUser?.uid else {return} Database.database().reference().child("users").child(uid).observeSingleEvent(of: .value, with: { (snapShot) in print(snapShot.value ?? "") guard let dictionary = snapShot.value as? [String: Any] else {return} // let profileImageUrl = dictionary["profileImageUrl"] as? String // let username = dictionary["username"] as? String self.user = User(dictionary: dictionary) self.navigationItem.title = self.user?.username self.collectionView?.reloadData() }) { (error) in print("Failed to fetch user", error) } } } struct User { let username : String let profileImageUrl : String init(dictionary: [String:Any]) { self.username = dictionary["username"] as? String ?? "" self.profileImageUrl = dictionary["profileImageUrl"] as? String ?? "" } }
RichyCode
5 years ago
copied and pasted the code from swift 4.1 into my profile and cant even get the red circle Brian, nothing showing at all just the blue header... code is identical to the sample project, any ideas Please? thanks
RichyCode
5 years ago
not profile image appears for swift version 4.2, just a blue background, ive copied every file into mine any ideas? just get a header....no image
Viswa Kodela
5 years ago
Maybe you forget to call the reloadData() method for the ColllectionView it will be like as follows collectionView.reloadData() in the fetchUser() method.
RichyCode
5 years ago
im using the sample project so its not that, clearly an issue somewhere possibly firebase dont know
tientran13
5 years ago
did you ever find the solution to this issue? Im on swift 4 and i'm having the same problem where its not showing the red circle. Its not showing at all even setting the background color of the cell to .white
Brian Voong
5 years ago
tientran13
5 years ago
Thank you found my problem!
djibh
5 years ago
What was it ? I have the same issue. If I put an image in the UIImageView is does show up. (not resized according to anchors though)
djibh
5 years ago
Nvm, I just lost 30 minutes of my life for a missing "isActive = true" for my height/width anchors extension... FML
moopoints
5 years ago
Hey Brian. My profile image stays empty - printing the username/image from the UserProfileHeader file I only get nil as results. I am assuming that as I am passing the user from the UserProfileController to the UserProfileHeader, the user hasn't been loaded yet. That is visible as well from the fact that the username in the navigation title only appears after a second or so (10 Mbit Internet connection here). What's a good way to pass it on completion again?
RichyCode
5 years ago
you wont get a response on here as brian is away i think, send a tweet. Im still having issues getting anything to display at all even with the sample project. Clearly an issue that needs looking at
dclawson
5 years ago
I've been looking at this for a bit now. I set some breakpoints in the "didSet" method on the "user" var within "UserProfileHeader.swift". It looks like "didSet" never gets called, because nothing is ever "set". As a result "setupProfileImage()" is also never called. It seems like the UserProfileHeader's viewDidLoad() would have to call it somehow, or set the "user" var to something? Has anyone figured this out?
frankcrest
5 years ago
man..im stuck on dis one too
Brian Voong
5 years ago
Patrizio
5 years ago
Hi Brian, Why does the 'didSet' code of the 'UserProfileHeader' is executed only once and when the user variable is still 'nil', when I don't force the reload of data with the self.collectionView.reloadData() call in the fetch user function although the fetchUser() is called in the viewDidLoad before registering the profile header?
Brian Voong
5 years ago
frankcrest
5 years ago
@17.35, my url session print(data) prints Task finished with errorcode -1002, nil. anyway how to fix?
Brian Voong
5 years ago
frankcrest
5 years ago
well i finished running the project from download it still doesnt show a picture
Brian Voong
5 years ago
frankcrest
5 years ago
Hi Brian, the url simply gives me back the name of the picture. the url is 9BA3C5F8-AB1F-490C-9ACA-A276761B038E i tested this with a print statement in UserProfileHeader file
Brian Voong
5 years ago
frankcrest
5 years ago
how do i go back to the initial screen? since right now the program is stuck with no buttons to go back
Brian Voong
5 years ago
frankcrest
5 years ago
perfect it worked, thanks a bunch!
Brian Voong
5 years ago
Daniel Peach
5 years ago
Can you explain or point to somewhere that can what calling UICollectionViewCell.self (or any iteration of Class.self) does?
Brian Voong
5 years ago
MaxApp
5 years ago
Hey Brian, I did not understand this block of code: override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerID", for: indexPath) as! UserProfileHeader header.user = self.user return header } why did you do header.user = self.user and also how did the setupProfileImage() function run when you never called it did it run because you did this var user: User? { didSet { setupProfileImage() } } thanks
Brian Voong
5 years ago
Hwang.the.human
5 years ago
Hello, Brian! I am sorry for bothering you, but I just wonder what these errors mean? Should I pay attention to them? Or just leave them alone? (App does not crash) 2019-04-04 22:37:17.116555-0700 InstagramFake[9806:1099219] - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist 2019-04-04 22:37:17.312166-0700 InstagramFake[9806:1099226] 5.16.0 - [Firebase/Analytics][I-ACS023007] Analytics v.50500000 started 2019-04-04 22:37:17.313010-0700 InstagramFake[9806:1099226] 5.16.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r) 2019-04-04 22:37:17.639495-0700 InstagramFake[9806:1099219] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x7fd261714930] get output frames failed, state 8196 2019-04-04 22:37:17.639632-0700 InstagramFake[9806:1099219] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x7fd261714930] get output frames failed, state 8196 2019-04-04 22:37:17.640364-0700 InstagramFake[9806:1099219] TIC Read Status [1:0x0]: 1:57 2019-04-04 22:37:17.640522-0700 InstagramFake[9806:1099219] TIC Read Status [1:0x0]: 1:57 2019-04-04 22:37:17.755436-0700 InstagramFake[9806:1099219] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C2.1:2][0x7fd26170a000] get output frames failed, state 8196 2019-04-04 22:37:17.755538-0700 InstagramFake[9806:1099219] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C2.1:2][0x7fd26170a000] get output frames failed, state 8196 2019-04-04 22:37:17.759107-0700 InstagramFake[9806:1099219] TIC Read Status [2:0x0]: 1:57 2019-04-04 22:37:17.759380-0700 InstagramFake[9806:1099219] TIC Read Status [2:0x0]: 1:57 2019-04-04 22:37:18.294474-0700 InstagramFake[9806:1099246] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C4.1:2][0x7fd261714930] get output frames failed, state 8196 2019-04-04 22:37:18.294598-0700 InstagramFake[9806:1099246] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C4.1:2][0x7fd261714930] get output frames failed, state 8196 2019-04-04 22:37:18.294909-0700 InstagramFake[9806:1099246] TIC Read Status [4:0x0]: 1:57 2019-04-04 22:37:18.294995-0700 InstagramFake[9806:1099246] TIC Read Status [4:0x0]: 1:57 2019-04-04 22:37:18.402058-0700 InstagramFake[9806:1099228] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C6.1:2][0x7fd261624ca0] get output frames failed, state 8196 2019-04-04 22:37:18.402389-0700 InstagramFake[9806:1099228] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C6.1:2][0x7fd261624ca0] get output frames failed, state 8196 2019-04-04 22:37:18.402896-0700 InstagramFake[9806:1099228] TIC Read Status [6:0x0]: 1:57 2019-04-04 22:37:18.403029-0700 InstagramFake[9806:1099228] TIC Read Status [6:0x0]: 1:57 2019-04-04 22:37:18.601013-0700 InstagramFake[9806:1099219] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C8.1:2][0x7fd261423b50] get output frames failed, state 8196 2019-04-04 22:37:18.601218-0700 InstagramFake[9806:1099219] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C8.1:2][0x7fd261423b50] get output frames failed, state 8196 2019-04-04 22:37:18.601564-0700 InstagramFake[9806:1099219] TIC Read Status [8:0x0]: 1:57 2019-04-04 22:37:18.601776-0700 InstagramFake[9806:1099219] TIC Read Status [8:0x0]: 1:57 2019-04-04 22:37:18.855274-0700 InstagramFake[9806:1099228] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C7.1:2][0x7fd261519870] get output frames failed, state 8196 2019-04-04 22:37:18.855455-0700 InstagramFake[9806:1099228] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C7.1:2][0x7fd261519870] get output frames failed, state 8196 2019-04-04 22:37:18.855966-0700 InstagramFake[9806:1099228] TIC Read Status [7:0x0]: 1:57 2019-04-04 22:37:18.856120-0700 InstagramFake[9806:1099228] TIC Read Status [7:0x0]: 1:57
Hwang.the.human
5 years ago
Also, is that possible to fix them?
Brian Voong
5 years ago
Hwang.the.human
5 years ago
Hello again! For some reasons, I cannot see a profile image, there is only a red circle. Even though if I copied everything from your code, it still does not work, and I could not run your project, it pops up a lot of errors.
Brian Voong
5 years ago
Hwang.the.human
5 years ago
Hmm, it is kind of weird because I run your project, and I put my GoogleService-Info.plist, and I still see the red circle.
Hwang.the.human
5 years ago
Oh, never mind, your project is working well. I think I missed something.
Steve Vicario
5 years ago
You have made this so simple. Thanks for sharing your knowledge Brian!
Mike Zhang
4 years ago
Hello Brian, I have two errors. One is that NavigationBar does not display the user name. One does not display the user image. I have downloaded your code and run it. But the screen does not display the user name and user image.
Mike Zhang
4 years ago
How did I just post a question? The comment shows that the time was four months ago ==?
yaostyle
4 years ago
If you get stuck with UICollectionElementKindSectionHeader syntax error, it's now UICollectionView.elementKindSectionHeader in Swift 4.1+. New syntax to register header: collectionView.register(UICollectionViewCell.sef, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "headerId")
hflournoy
4 years ago
Hi Brian, I'm getting this error: "Value of type 'User' has no member 'profileImageUrl' " All code is identical. Any thoughts? I'm now in Xcode 11 Kind regards, Champe
hflournoy
4 years ago
fileprivate func setupProfileImage() { guard let profileImageUrl = user?.profileImageUrl else { return } guard let url = URL(string: profileImageUrl) else { return } this is leaving the error
Brian Voong
4 years ago
hflournoy
4 years ago
oh sweet! I didn't know you updated to Firebase 5.0 sdks...I'll do that shortly Brian! Thank you.
thomasfqb
4 years ago
Even with copy and paste of the exact same code you'll probably still get the error, it's a Xcode bug. you can hit cmd + shit + K to clean the workspace and close and reopen XCode and the error will go away !
Kyle Griffin
4 years ago
I had a job offer from a company to do React / Node.js. they cancelled that position shortly after. Now they want to see if I'd like to join the iOS team instead and see if I can get up to speed in 3-6 months...anyone think I can do it? I have an interview with the software lead in about 9 hours lol.
djsatoda
4 years ago
Sure!
abreyXo
4 years ago
Hey Brian, Ive followed everything step by step and checked the sample code too, but my profile image isn't uploading onto the profile pictures circle. Even when I did lecture 5 and seen my imageURL pop up inside the console debug area and then copied and downloaded that onto safari, it didn't let me open the image up with preview unless I changed the pictures extension to .jpg Thanks
Page
3 years ago
The user image doesn’t show using this code are there any solutions for this func setupProfileImage() { guard let uid = Auth.auth().currentUser?.uid else { return } Database.database().reference().child("users").child(uid).observeSingleEvent(of: .value, with: { (snapshot) in print(snapshot.value ?? "") guard let dictionary = snapshot.value as? [String: Any] else { return } guard let profileImgeURL = dictionary["ProfileImageUrl"] as? String else{ return} guard let url = URL(string: profileImgeURL) else {return} URLSession.shared.dataTask(with: url) { (data, response, error) in if let err = error { print("failed to show", err) return } guard let data = data else {return } let image = UIImage(data: data) DispatchQueue.main.async { self.ProfileImage.image = image } }.resume() } )}
dannyp75
3 years ago
Brian, I want to remove the posts/follower/following text and the Edit Profile button and center the Profile pic and user name. I commented out the elements for now. What's the easiest way to center the profile pic and username? Do I need to delete all the code for the text and button or can I leave it commented out and reposition the two elements I want?
HELP & SUPPORT