r/iOSProgramming • u/ordosalutis • Sep 01 '20
Discussion Honestly I can't get enough of Diffable Data Source
6
u/mynewromantica Sep 02 '20
I would love more of an explanation on how your doing this.
10
u/ordosalutis Sep 02 '20
It's done with
UICollectionViewDiffableDataSourceandNSDiffableDataSourceSnapshotWith SearchController, you would use the delegate method
updateSearchResultsand whenever the text is being inputted, you update the snapshot accordingly. In this particular video, it was done on a custom view with no nav bar so I had to improvise with a UITextField, and whenever the textField'seditingChanged, I would update the snapshot.Watch this video from WWDC19's introduction to diffable data source and other related videos. Also watch u/twostraws 's video. This one was especially super helpful.
Another great resource is from Sean Allen's Take Home Project course
2
u/ALonelyDev Sep 02 '20
This is amazing!!! Also hello fellow Canadian 🇨🇦
2
u/ordosalutis Sep 02 '20
Thank you! I just love how much you get using diffable data source. So very thankful. And hello to you too! 🇨🇦🇨🇦🇨🇦
6
Sep 02 '20
These and Compositional Layouts have been such a nice upgrade. Love actually being able to work on projects with reasonable minimum OS targets
2
Sep 02 '20
+1, compositional layouts are a game changer for me too, plus they've added a few nice things to both the layouts and the diffable data sources on the upcoming iOS 14
3
u/GuitarIpod Sep 02 '20
What do you mean? They are both iOS 13 <
1
Sep 02 '20
I mean I’m currently on two projects, one of which is older and still supporting iOS 9 and the other of which is yet to release and has a a minimum of 13. So it’s nice to be able to use those APIs instead of the old school way for iOS 9
2
0
u/alwaysSearching23 Sep 02 '20
iOS apps usually support the current OS and previous right?
5
u/ndg91 Sep 02 '20
Maybe new apps, on existing apps its harder to ditch the original version especially when working for a client (that usually doesnt care about code level improvements but cares about that 0.5 percent of users on 4 year old OS).
6
u/wesleyjacobs Sep 02 '20
This is so true... Luckily there is a pretty good port of the DiffableDataSource to make it backwards compatible with iOS 11 at least (not sure about 10), which I’ve been using with some success.
1
2
Sep 02 '20
For my one of my clients we’re just finally switching the minimum from 9 to (I think) 11. So no, not exactly
5
u/USERNAME_ERROR Sep 02 '20
Hi, I’m glad you’re enjoying this (: I’m a UX/UI designer, so some tips:
Consider the “why” of this feature. Does the animation help or distract from the user’s goal?
If like me you agree it only distracts without giving much benefit, consider where it might be useful. In particular, where the movement of elements might be appreciated by users?
I can think of a couple of situations, but mostly it boils down to:
having all items be familiar ahead of time
have all items be visible upfront (so nothing “appears out of nowhere”
movement should bring relevant items closer to finger
In general, be more critical of the toys Apple brings to your toy box. It’s fun, but design should serve users (:
1
u/amikiri Sep 02 '20
Thank you!
Not a UI/UX designer but this has essentially been my mantra as an iOS developer (and probably one of the reasons I just lost my job They were more interested in doing cool stuff than serving the user). When someone asks me "can X be done" my response is usually along the lines of "yes, but should it be done?"
2
u/USERNAME_ERROR Sep 02 '20
I have no idea about your situation, but I like to dedicate at least 20% of dev effort to delighting users. Can be a useless thing, like a nice loader or transition or animation, but it lifts apps from transactional to beloved.
2
2
u/the_d3f4ult Sep 02 '20
Well, tbh diffable data sources might feel like something good, but these puppies are actually super bad.
They are unperformant and inefficient, only fit for small changes and small data sets. Bigger data sets and bigger changes are quite inefficient.
Consider, that if you're applying a snapshot with animations, that diffable data source creates each new cell (so for 1000 new items, 1000 new cells, allocated and initialized serially). For bigger snapshots and cells with complex initialization, it both freezes the UI (before performing initialization) and then produces lagging and chopping. (This was clarified to me by engineers in feedback, where they said that it's my fault, because I animate the change, so diffable data source has to animate it all ...cell by cell.... what?!)
So yeah, kinda nice, animations are cool (maybe), but totally inefficient.
-1
u/lordzsolt Sep 02 '20
Now imagine this didn't take 12 iOS versions to add, from when Uitableview came out....
0
Sep 02 '20
[deleted]
6
u/ordosalutis Sep 02 '20
honestly my UI/UX is very subpar and weak to say the least.
-1
Sep 02 '20
Not to be a dick, but isn’t this copy pasta from the WWDC video?
4
u/ordosalutis Sep 02 '20
I mean more or less in terms of UI/UX sure. Like I said im not the best in that regard so I have little to zero creativity.
17
u/sumnuyungi Sep 02 '20
Wish you could get enough manners.
If you have something to say, make it constructive or keep it to yourself next time.
1
u/IAmKindaBigFanOfKFC Sep 02 '20
Dude. This looks like a primitive UI and UX, but it's obviously a prototype.
13
u/Soupnoodledumpling Sep 02 '20
How do I do dis?