Swift 3: Twitter - Easy Caching and Loading Images using CachedImageView (Ep 15)

preview_player
Показать описание
Today, let's look at how to easily load and cache images we need from external sources using CachedImageView, a component included inside of LBTAComponents. We'll be using our user profile image urls from the JSON dictionaries to demonstrate how easy this really is.

Finally, I'll go over sizing our tweet cells to be the appropriate height based on the message while also refactoring the size estimation code.

Enjoy.

Facebook Group

iOS Basic Training Course

Completed Source Code

Рекомендации по теме
Комментарии
Автор

The LBTAComponents Library deserves the highest award achievable to MAN!!! Every episode you show how this library drastically saves time in writing the same exact functionality in code. This image downloading and caching piece sealed the deal for me 😲😲😲😲. I will definitely use this library in these types of apps! I look forward to the next Episode!!!

marcaupont
Автор

Another great tutorial as caching is going to play a big part in my startups app.

DannyPimienta
Автор

how many app projects are you involved in, in a year - or how many apps are you involved with? also do you normally do backend also or do you just work on the app logic and someone else do service side ...normally?

brucen
Автор

can you please make a tutorial to show
how to make this twitter app able to show the tweet feed when the app is offline?
you made a great tutorial as always

anonimkisi
Автор

I did a sample app inspired by this video. I am not sure if you can review the code and let me know if there are problems like leaks, wrong design pattern etc. ?

Navyarakhan
Автор

Thanks for your video tutorial. They are fantastics.
But after I watched your video, I have a question:
I don't know if I was wrong but I think that function sizeForItemAt will be called before the function cellForItemAt. (The size will be setup first)
So I curious about how you can access and get data from the cell when you're at the size function (because I think at this time, the cell is empty)

vietanh
Автор

Hi really like what you are doing. will you port the same series for android?

akashgutha
Автор

I liked the CachedImageView class. It's cool that you have a way to pass a completion block for a tap handler. Does your cache get stored both in RAM and to flash? Is there a way to set the expiry. Is there a way to flush the in memory cache so it can be called from didReceiveMemoryWarning?

jimlong
Автор

Well it is official! I hate to work anymore WITH storyboard and WITHOUT LBTAComponents :)

iamcanarin
Автор

Hi Brian, why have UIImage property in user model. My understanding is that always keep UI property out of model object and inside model file shouldn't have to import UIKit.

I might be wrong, please enlighten me .

Thank you!

ff
Автор

Thank you brain for this awesome work!

abdouett
Автор

This is a very important utility.. thanks for teaching thiss

abhisheksitar
Автор

Hi Brian, sorry about bodering you again.. I'm stacked for 3 days already.
I'm following all your examples.. to create collectionViews with other collectionViews inside of them.. and throw all those collections I pass only one parameter.

var accounts: Accounts? {
didSet {

}
}

All my collection header and cells and everything is populated with data..its ok. But when I'm trying to access a cell which has also collectionview inside, from the root collectionView, this cell's parameter "accounts" is nil.. It's because this account parameter initialized once, and it is no longer keeps the reference... or how this works...?? help please, with short advice.. I used stackoverflow, but you defenitely know what I'm talking about..

I have collection view(1), inside of that collectionView(1) is another collection(2) with one header(H) and one cell(c), inside of that cell i have also collectionview(3)... In header(h), I have button, and when I hit this button I want to add element to collectionView(3)cell... but this account is nil there... because it was initialized at the beginning, and what happens I don't know....
pfff((

Igor-rruc
Автор

gett error when trying to install pod Analyzing dependencies
[!] Unable to find a specification for `LBTAComponents (~> 0.1.9)`

iehsan
Автор

Hi, another great tutorial. I sort of jumped ahead a few videos ago and implement the height thing myself. But what I did saves a tiny bit of code and I wonder if it's a wrong approach. Instead of checking the indexpath of the section to return the height, then guarding if the item can be cast as a user/tweet, I just had

if let user = datasource?.item(indexPath) as? User {
...
} else if let tweet = datasource?.item(indexPath) as? Tweet {
...
}
It does work I just wonder if there is anything inherently wrong with doing what I did.
Thanks.

sminkly
Автор

Hi Brian, very simple question: Why you use mostly Objective-C classes over Swift classes, such like "NSString" over "String"?

gchriswill
Автор

hi, how can we set two datasource ? my tweet model doesnt have user, so i have user array and tweet array.

mustafavolkangurol
Автор

Hey Brain,
Thank for video. just wanted to ask how your app is even working without turning off ATS in info plist, How???

isuryakantsharma
Автор

How to cache JSON.? I tried but its only work till app not close.

brainload
Автор

Brian, I have been testing using cache for some time using what you were doing. For some reason sometimes the content is mixed up or shows duplicates of the image when it should not be there. Have you noticed this as well?

markw