there's something missing between this video and the one before it, in the one before it you didn't have FeedCell file and image url was not yet set up.
Hi .. I am big fan your turorials..in this video you said how to use Nsurlsache ,can you tell us how to clear or reset the Nsurlcache when Nsurlcache becomes full
What the better way? Use the default cache provided by NSURLSession or use my own cache maked using NSCache class? If i use NSURLSession and implement a cache using NSCache, therefore some images are cached twice? (NSURLSession and my NSCache object)
Excellent tutorials. How did you add ActivityIndicatorView to FeedCell while downloading the image. It is not explained in this video, Is it in different video?
Awesome tutorials I must say Brian. You have influenced a lot of my coding style thanks a loooooooooooot. There's actually a gap between this video and the previous one. Some files (e.g Posts.swift, Extensions.swift, FeedCell.swift) weren't in the previous video. I have tried to recreate these files myself but I keep running into errors from the FeedCell.swift file. Please help. Thanks.
Hi Brian, Hope you are doing good. Such a nice tutorial. I have a question when should I use this tutorial method and when should I use third party lib like AFNetworking etc. Thanks in advance:)
Hey, Brain I have a tableViewCell in which I am getting dynamic image size according to which I have to calculate image height but while using this code for getting image height. let imageURL = URL(string: strImageUrlPath) var imageData: Data? if imageData == nil { if let imageURL = imageURL { imageData = Data(contentsOf: imageURL) } } var img: UIImage? = nil if let imageData = imageData { img = UIImage(data: imageData) } scrolling of table view got stuck or some times zerk while scrolling . please give me some solution for that.
Thanks for another great tutorial. I'm quite new to Swift but I see your way of set things up programmatically is somehow more organized and easier to see the whole picture. But I'm still on two minds whether I code my project without storyboard because I'm afraid I can't find good lessons on the internet when I hit a bump in the road. As you know, almost all the lessons use storyboard and your way is quite special. Can you suggest me any advice on this? What can be the best way to improve my coding or solve any issue when I do it programmatically?
Like you mentioned above, doing things programmatically is more organized and easier to follow what is going on. Here's a statement that usually holds true: If you know how to do something in code, you will most likely know or will be able to figure out how to do it in a storyboard. I can't say that the inverse holds true. Also the major difference for me is that while I can use storyboards for a lot of projects, I can use the programmatic approach for all projects.
Hello Nicholas. You should be able to perform similar caching if you can get access to the downloaded video file. I've never had to handle this but I'd be surprised if this issue hasn't been solved on StackOverflow.
Thanks for putting this together. Really helpful stuff for getting me started with ios dev. Really interested with the paid lessons on your site. Just a question though. There seems to be missing video in this series; factoring out the data and code for the loader and server calls. Tried searching from your list but couldn't find it. Thanks so much.
Do you think the best way to link the tableView data to the imageViews etc. is with the didSet inside the custom cell class like you did here? I'm just asking because I used to link it in cellForRowAtIndexPath and since this video is a little older by now, maybe you found another way you would consider as better? If not I will change my code and also use didSet inside the cell class :) Thanks for you great videos, I learned a lot from you!
It is best to keep your controllers really simple and not have them be aware of how cells are rendered. This way you implement separation of concern for your classes.
Okay thanks a lot for your answer :) also performance wise it should be pretty good? Cause I had some problems with the scrolling sometimes it was a little choppy, just very little but noticeable
Brian, thank you so much for the great tutorials. I have a question- would you have any idea why the scrolling in the collectionview seems very choppy even caching the images? Thanks
Hi Joaquin, it could be your simulator that is choppy. Also, make sure you are storing the UIImage in the cache, also make sure the cache is actually getting back your uiimage objects instead of making another url request.
Lets Build That App Hey Brian thanks for the reply. I'm actually experiencing it on my phone as that's where I'm testing on. The images are being cached and not being fetched more than necessary. I have also tried upping the default cache. Any other pointers? Thanks a lot man. Huge fan
You are a champ Brian! Your continuous efforts in making people understand things practically are much appreciated. I tried the way of caching that you explained in RUclips app. Somehow it doesn't work. Is there a change in implementation for swift 3/4?
Really enjoyed this tutorial, thought it was great/interesting. Do large companies like Instagram or Facebook that have a lot of content in the form of photos/videos use similar NSURLCache methods?
Photos are definitely cached using their own sophisticated library where items are evicted in a very efficient process. You gotta go to one of their talks to see what is really under the hood for their apps.
Will this method also being use by WKWebView? let say i have a video intro(intro1.mp4) and of course within the WKWebView you are sending request(using interceptor(URLProtocol) you can browse each request within). If not are there any caching method that you can use for faster loading video?
You lecture is really awesome. I learn the depth of swift from you. Thank You so much. And I have a quesiton. What do you refer at the starting point? I mean, I proceed to study in the order of this "How to create Facebook's news feed" playlist, but maybe it's different between a completed source code of "Dynamic cell content" part and the code of this lecture at starting point. So what the other viewers refer? I wonder how to proceed, thank you.
Thanks for your reply, and I did refer the same playlist as you send me. But the source code is different, neither is the feed images. In the last part of "Dynamic cell content" lecture, the feed images is like DOG picture, JOBS picture seeing at 24:53. But in this lecture at start point, the feed images is totally different. Same in the source code.
Yes the code changes a bit. Apologies, I didn't intend for these episodes to be continuous. These videos were shot way way way back in feb/march, I was still getting used to presenting code while recording. From now on, I'll create continuous content that will be easy to follow.
Hi Brian thanx a lot for the video. But I have few questions 1. What is the size of default cache ? I saw in the above video 500KB image was fetching from network but 32KB image was in cache I guess it loaded faster. 2. Does AlamofireImage library takes care of caching ? 3. What is the maximum size I can define for cache ? you have set diskcapacity 500 * 1024 * 1024 ? How many MB's ?
First of all thanks for the tutorial! I have a question: Currently I'm using Firebase to store and fetch image. But I am experiencing a problem where the image are in the wrong tableviewcell even though the image urls in each cell are correct. Google told me that it was because the image files are too large and images are being overwritten (something to deal with async as well) Are there any ways I can solve this?
I run into this quite often, and ran into this while using firebase as well. I'll address it with my solution in a Firebase tutorial soon. Thanks for watching.
hiii,, what if i want to change the image without change the link..is that possible? if not>> can i load set of images (i will replace it weekly) from firebase to my app ? if not>> any solution plz??
Every time the application exits the cache is also cleared. How can I make the application not clear the cache once it exits? I don't want my app to load the images user once loaded every time the app is reopened. It's just like your web browser, your files are stored in a temporary folder until you delete the temporary files
The cache will not help you if you're trying to keep a persistent state of your files. I suggest looking into CoreData to store your files using a binary format. Another method is to store the files directly into your app.
Hi, I don't think there is a good video tutorial on using AlamofireImage. if you can make one (using all his features and explaining them) it will be great!
Awesome video! But, right now I'm having a problem. Every time collectionView bounces of the top, the first cell lags while going back to its position. Did Anyone have such problem?
I have an issue. It'll set the cell's image to a previous cells image, and then switch it a fourth of a second later to the correct image. What am i doing wrong?
Hi, I am trying to load 100 or more images in tableview using SDWebImage but after downloaded all images getting Error Message from debugger: Terminated due to memory issue and after App is Crashing
CDMusicGroup no, why would you? Since you’re displaying the imagine on the screen, you don’t need it to be a huge image. Just like Instagram, images are very low res cause you don’t need a huge image for a phone
Tapizquent ok, sounded like you were saying to compress it into a file of a different (similar to how a .zip is compressed). I’m now seeing you’re referring to resizing and reducing the resolution of the image. Am I understanding you better now or are we still not on the same page
(Min 6)Is it possible that there's no need to cache anymore(as of October 2017)? Because my images do not reload. It is as if the network request is made once and the image is automatically cached. Anyone experiencing the same thing? Thanks in advance
Make a Udemy tutorial. Id buy it instantly. intermediate to advanced topics for the swift language is a soft market there and you're course would sell like fire. just sayin'... I spend 50$ a month on courses there.
+Hunter Walker Thank you for the info regarding udemy. With the pricing changes and strictness of that platform, I'd have to continue monitoring before I step into that world.
you are the best! this is an understatement for you. please never stop making tutorials.
I love the way you implemented the activityIndicatorView on each StatusImageView.
Again, thanks for what you're doing.
Happy Sunday.
Thanks Andrea, going the extra mile to demonstrate a concept goes a long way.
Your way of explaining things is way super than others.... thanks for yet another amazing video....
And before i forget, congratulations! Your videos are amazing !
Once again an excellent tutorial! This one saved me a lot of time. Thank you Brian!
Can I get a cup of coffee with the time saved?
You are awesome . I actually learn everything in so detail in your channel . You're great .
Glad to help you on your coding journey Shivam
Nice tutorial.all cache basic is covered ,,,Really helpful...
Indeed, however there is much more about caching that I wish to go over in later videos.
Your tutorials are amazing man.
Thanks for that
+Yannsonnboys Yannick Great to be of service to you.
Hi Brian can you please make another video on how to properly clear the cache when it is full using different methods?
This is amazing. Thanks a lot.
Waiting for more tutorials
Thanks, I like your haircut!
Amazing tutorials , learnt a lot of stuff and made me a better programmer. Thank you.
Thank you so much man. You really helped me a lot. Please keep up the great work!
Great tutorial!! Thanks!!!
Man you are amazing! Thanks once again!
Great tutorials! Subscribed
+Thanasi Stratigakis thanks a lot, lots more coming!
Finished project with Latest Swift syntax here:
github.com/VamshiIITBHU14/FBClone
Thanks again for your sharing!!! Really hero
Great Tutorial :D Thank you for this :) keep up the good work.
there's something missing between this video and the one before it, in the one before it you didn't have FeedCell file and image url was not yet set up.
Is it possible to make image height dynamic in the cell, as you have done with status textview.
PS: when you have url of that image(dynamic content)
Thx for the great tutorial
You are amazing thanks alot for sharing your knowledge
Hi .. I am big fan your turorials..in this video you said how to use Nsurlsache ,can you tell us how to clear or reset the Nsurlcache when Nsurlcache becomes full
What the better way? Use the default cache provided by NSURLSession or use my own cache maked using NSCache class?
If i use NSURLSession and implement a cache using NSCache, therefore some images are cached twice? (NSURLSession and my NSCache object)
Great work
Excellent tutorials. How did you add ActivityIndicatorView to FeedCell while downloading the image. It is not explained in this video, Is it in different video?
great job , best of luck man :)
+Billion Bucks thanks for watching!
Awesome tutorials I must say Brian. You have influenced a lot of my coding style thanks a loooooooooooot. There's actually a gap between this video and the previous one. Some files (e.g Posts.swift, Extensions.swift, FeedCell.swift) weren't in the previous video. I have tried to recreate these files myself but I keep running into errors from the FeedCell.swift file. Please help. Thanks.
Excellent tutorial! Thank you so much, for saving my homework!! lol
Thanks! Is there any reason you used a dataTask vs a downloadTask? Wouldn't you want to use a downloadTask for images?
Hi Brian, Hope you are doing good. Such a nice tutorial.
I have a question when should I use this tutorial method and when should I use third party lib like AFNetworking etc.
Thanks in advance:)
Would you need to change anything in case you were getting dynamic data?
(some data may not be there anymore, new posts added)
The library that you mentioned at the end is this github.com/rs/SDWebImage?
Good lesson! Veay helpful
Hey, Brain I have a tableViewCell in which I am getting dynamic image size according to which I have to calculate image height but while using this code for getting image height.
let imageURL = URL(string: strImageUrlPath)
var imageData: Data?
if imageData == nil {
if let imageURL = imageURL {
imageData = Data(contentsOf: imageURL)
}
}
var img: UIImage? = nil
if let imageData = imageData {
img = UIImage(data: imageData)
}
scrolling of table view got stuck or some times zerk while scrolling .
please give me some solution for that.
Great video! But i have to ask, how did you learn about caching in swift, theres barely anything about it online
Thanks for another great tutorial. I'm quite new to Swift but I see your way of set things up programmatically is somehow more organized and easier to see the whole picture. But I'm still on two minds whether I code my project without storyboard because I'm afraid I can't find good lessons on the internet when I hit a bump in the road. As you know, almost all the lessons use storyboard and your way is quite special. Can you suggest me any advice on this? What can be the best way to improve my coding or solve any issue when I do it programmatically?
Like you mentioned above, doing things programmatically is more organized and easier to follow what is going on. Here's a statement that usually holds true: If you know how to do something in code, you will most likely know or will be able to figure out how to do it in a storyboard. I can't say that the inverse holds true.
Also the major difference for me is that while I can use storyboards for a lot of projects, I can use the programmatic approach for all projects.
I'm tying to figure out how to do this with videos. I'm guessing it's different because the action to play the video calls the URL everytime.
Hello Nicholas. You should be able to perform similar caching if you can get access to the downloaded video file. I've never had to handle this but I'd be surprised if this issue hasn't been solved on StackOverflow.
Thanks for putting this together. Really helpful stuff for getting me started with ios dev. Really interested with the paid lessons on your site. Just a question though. There seems to be missing video in this series; factoring out the data and code for the loader and server calls. Tried searching from your list but couldn't find it. Thanks so much.
Not sure if I actually show how to refactor the code. It's just simple practice to clean up projects after a while.
Do you think the best way to link the tableView data to the imageViews etc. is with the didSet inside the custom cell class like you did here? I'm just asking because I used to link it in cellForRowAtIndexPath and since this video is a little older by now, maybe you found another way you would consider as better? If not I will change my code and also use didSet inside the cell class :) Thanks for you great videos, I learned a lot from you!
It is best to keep your controllers really simple and not have them be aware of how cells are rendered. This way you implement separation of concern for your classes.
Okay thanks a lot for your answer :) also performance wise it should be pretty good? Cause I had some problems with the scrolling sometimes it was a little choppy, just very little but noticeable
Brian, thank you so much for the great tutorials. I have a question- would you have any idea why the scrolling in the collectionview seems very choppy even caching the images? Thanks
Hi Joaquin, it could be your simulator that is choppy. Also, make sure you are storing the UIImage in the cache, also make sure the cache is actually getting back your uiimage objects instead of making another url request.
Lets Build That App Hey Brian thanks for the reply. I'm actually experiencing it on my phone as that's where I'm testing on. The images are being cached and not being fetched more than necessary. I have also tried upping the default cache. Any other pointers? Thanks a lot man. Huge fan
You are a champ Brian!
Your continuous efforts in making people understand things practically are much appreciated.
I tried the way of caching that you explained in RUclips app.
Somehow it doesn't work. Is there a change in implementation for swift 3/4?
I would recommend looking at my cache implementation from LBTAComponents or browsing the source code for SDWebImage.
Hi Brian, thank you for this amazing tutorial. One question: the images remains in cache when the app is in background mode?
Great! Thank you.
Really enjoyed this tutorial, thought it was great/interesting. Do large companies like Instagram or Facebook that have a lot of content in the form of photos/videos use similar NSURLCache methods?
Photos are definitely cached using their own sophisticated library where items are evicted in a very efficient process. You gotta go to one of their talks to see what is really under the hood for their apps.
Ok, just wondering how translatable code is between smaller scale developers and the big boys! Thank you for your reply.
How can we find these talks?
Will this method also being use by WKWebView? let say i have a video intro(intro1.mp4) and of course within the WKWebView you are sending request(using interceptor(URLProtocol) you can browse each request within). If not are there any caching method that you can use for faster loading video?
Yes, don't use WKWebView.
Hi, it's also work, when I disappear this view, and back to him? whether will be download again? I mean in NSURLCache way.
You lecture is really awesome. I learn the depth of swift from you. Thank You so much.
And I have a quesiton.
What do you refer at the starting point? I mean, I proceed to study in the order of this "How to create Facebook's news feed" playlist, but maybe it's different between a completed source code of "Dynamic cell content" part and the code of this lecture at starting point. So what the other viewers refer? I wonder how to proceed, thank you.
Hello David, You should watch the entire FB tutorial series using this playlist: ruclips.net/p/PL0dzCUj1L5JHDWIO3x4wePhD8G4d1Fa6N
Thanks for your reply, and I did refer the same playlist as you send me. But the source code is different, neither is the feed images. In the last part of "Dynamic cell content" lecture, the feed images is like DOG picture, JOBS picture seeing at 24:53. But in this lecture at start point, the feed images is totally different. Same in the source code.
Yes the code changes a bit. Apologies, I didn't intend for these episodes to be continuous. These videos were shot way way way back in feb/march, I was still getting used to presenting code while recording. From now on, I'll create continuous content that will be easy to follow.
I see. Thank you!!
Hi can i ask something?What happens if there is no internet connection , can someone see the images that were cached before?
very nice explanations , but you do not use the storyboard?
+Victor Alves I like typing everything in code, call me old school :)
Oldschool
Hi Brian thanx a lot for the video. But I have few questions 1. What is the size of default cache ? I saw in the above video 500KB image was fetching from network but 32KB image was in cache I guess it loaded faster. 2. Does AlamofireImage library takes care of caching ? 3. What is the maximum size I can define for cache ? you have set diskcapacity 500 * 1024 * 1024 ? How many MB's ?
You should read the documentation on NSCache.
Ahmed did u find out?
setSharedUrlCache in Swift 4.2?
Thanks for he tutorial! But why there is a gap between this and previous video? In which part have you wrote that new code part???
+Orkhan Alizade Happy hunting my child
Lets Build That App excuse me?
haha that was random
First of all thanks for the tutorial!
I have a question: Currently I'm using Firebase to store and fetch image.
But I am experiencing a problem where the image are in the wrong tableviewcell even though the image urls in each cell are correct.
Google told me that it was because the image files are too large and images are being overwritten (something to deal with async as well)
Are there any ways I can solve this?
I run into this quite often, and ran into this while using firebase as well. I'll address it with my solution in a Firebase tutorial soon.
Thanks for watching.
+Lets Build That App Awesome! Subbed and thanks!
hiii,,
what if i want to change the image without change the link..is that possible?
if not>> can i load set of images (i will replace it weekly) from firebase to my app ?
if not>> any solution plz??
Every time the application exits the cache is also cleared. How can I make the application not clear the cache once it exits? I don't want my app to load the images user once loaded every time the app is reopened. It's just like your web browser, your files are stored in a temporary folder until you delete the temporary files
The cache will not help you if you're trying to keep a persistent state of your files. I suggest looking into CoreData to store your files using a binary format. Another method is to store the files directly into your app.
Hi, I don't think there is a good video tutorial on using AlamofireImage. if you can make one (using all his features and explaining them) it will be great!
11:38 swift 4 update:
var imageCache = NSCache()
what about video preloading ?
I suggest using HLS for video playback speed improvements.
Awesome video! But, right now I'm having a problem. Every time collectionView bounces of the top, the first cell lags while going back to its position. Did Anyone have such problem?
I have an issue. It'll set the cell's image to a previous cells image, and then switch it a fourth of a second later to the correct image. What am i doing wrong?
+Caelan Dailey probably cell recycle affecting your app
same problem. is there a solution?
Brian I'd like to ask if I can follow you on facebook or twitter.
Yes you can follow me on twitter at @buildthatapp
Hi,
I am trying to load 100 or more images in tableview using SDWebImage but after downloaded all images getting Error Message from debugger: Terminated due to memory issue and after App is Crashing
Cool, check the memory usage of your app
thanks for your reply, now i identified problem is loading high resolution images in tableview
Yeah you'll bust the memory limit real quick with high res images.
sir is it possible to link Facebook's news feed to this app
Hello Pavan. Unfortunately, Facebook does not allow developers to replicate behavior similar to their iOS app.
What about twitter?
Why not compress the image instead of bumping the cache up?
Why not both?
would we then need to decompress the image after grabbing it from the cache and presenting it to the collection view?
CDMusicGroup no, why would you? Since you’re displaying the imagine on the screen, you don’t need it to be a huge image. Just like Instagram, images are very low res cause you don’t need a huge image for a phone
Tapizquent ok, sounded like you were saying to compress it into a file of a different (similar to how a .zip is compressed). I’m now seeing you’re referring to resizing and reducing the resolution of the image. Am I understanding you better now or are we still not on the same page
CDMusicGroup you are right. I was just referring to saving a smaller image.
(Min 6)Is it possible that there's no need to cache anymore(as of October 2017)? Because my images do not reload. It is as if the network request is made once and the image is automatically cached. Anyone experiencing the same thing? Thanks in advance
It all depends on how fast your internet connection is. Caching comes into play on 3g and much bigger apps.
Oh okay, thanks Brian
Make a Udemy tutorial. Id buy it instantly. intermediate to advanced topics for the swift language is a soft market there and you're course would sell like fire. just sayin'... I spend 50$ a month on courses there.
+Hunter Walker Thank you for the info regarding udemy. With the pricing changes and strictness of that platform, I'd have to continue monitoring before I step into that world.
wasted 20 min... this is no longer applicable