User Profile Pagination Part 1
Instagram Firebase
Pagination often comes up when working with Firebase and building social media applications. The reason for this is because pagination allows us to more quickly fetch data from Firebase Database. In this lesson, I'll walk you through how to implement this very tricky feature. First we'll tackle how to paginate through Post objects in the User Profile screen. In order to do so, we implement a few tricks on cellForItemAt to trigger the pagination process. Once you complete this lesson, you'll be ready to move onto paginating through data and sorting based on a key such as creationDate on our Post model.

Comments (20)
GeminixClown
6 years ago
Omg finally... im so excited
Brian Voong
6 years ago
xd573797483
6 years ago
This is awesome, thank you Brian.
Brian Voong
6 years ago
Jeffrey Chang
6 years ago
Thank Brian
Vartis
6 years ago
Finally !! Thank you Brian
shender ramos
6 years ago
thank you brian great work as always man...
Razzor Owa
6 years ago
WOW!!! Finally! I can't wait to watch it.
esneaker
6 years ago
Holy smokes!
jacquesj
6 years ago
Awesome stuff man!
jacquesj
6 years ago
Awesome stuff man!
Casey West
6 years ago
Finally have time to take a look at this. Thanks a ton :) Incredibely informative as usual.
stonypig1
6 years ago
app or user setting page ? how to connect a button in setting page to enable or disable the functionality i have been search this course and lots of other places none of them discuss about how to make a setting page of an app, which i think it is essential for every app? maybe it is very easy, but i just can't think through how to enable/disable a button to activate the funationality of that button, please give me some hint or show me any online article if that is available, thanks very much
h01m3s
5 years ago
Haven't done this before but I guess you might want to use UserDefaults to store user settings.
David Wu
5 years ago
Hi Brian! Thanks for the awesome lesson today. But why removeFirst()? It takes O(n) of time while removeLast() takes O(1) time. Also I was thinking that remove first will get rid of your first post while actually it doesn't. A little bit confused!
Brian Voong
5 years ago
David Wu
5 years ago
Thanks for the quick reply. I'm actually making an app that people can post their video together with subtitle files so that the public can see how the subtitles he/she makes work with the video. In my case, pagination will be very important since I need to load a limited number of thumbnail pics (as well as other data related to the video) for each scroll. I think I will need to go through these two pagination lessons a couple times and get back to some more detailed comments here. Thanks again for the great lessons.
David Wu
5 years ago
Okay, now I get that allObjects is refreshed every time of the pagination, and the number of items in the array of allObjects is equal to or less than the number of items you intend to retrieve each scroll, which is a rather small number. So it's not much different if it's whatever time complexity. The process is a bit tedious indeed but it's such a helpful solution.
Brian Voong
5 years ago
Polas Opel
5 years ago
Why do we have to use allObjects and cant use snapshot.value instead? , isnt that the same thing kind of?
Brian Voong
5 years ago
Drew Pasma
5 years ago
Didn't see it in the comments so I'll be that guy.. Any hints on how to do this for the Home Feed?
ozolc
5 years ago
I would like to see this too, Brian
Aurélien Haie
5 years ago
I guess you have to trigger the paginatePosts() when you reach the bottom of the collectionView or when the footer appears on screen.. Maybe we'll see that in the next videos
Stephan Dowless
5 years ago
email me at dowless.stephan@gmail.com if you would like to know how to paginate home feed
Stephan Dowless
5 years ago
email me at dowless.stephan@gmail.com for how to paginate home feed
stonypig1
5 years ago
I have a general question about pagination, pagination only load a few posts of data first, and load more once the user scroll down. if we don't use pagination, once we load the app, are we downloading all the post data or just a few that show up on the iPhone screen ? anyone know ? thanks
Aurélien Haie
5 years ago
I think the whole data is loaded if we don't use pagination, that would explain the interest of this technique in order to avoid bulk loading
stonypig1
5 years ago
got it, and thanks for reply
Stephan Dowless
5 years ago
email me at dowless.stephan@gmail.com to find out how to paginate home feed
Daibaku
4 years ago
You are always my hero! Thank you for everything:)
anantangad
4 years ago
Hello Brian, Can you show how to implement the options button?
jungcom
4 years ago
Amazing video! Thanks as always!
Cinquain
4 years ago
I’m not even gonna lie, I didn’t expect pagination to be that involved. I’m gonna have to watch this video a few times
Brian Voong
4 years ago
Cinquain
4 years ago
that's a good point!
HELP & SUPPORT