Had fun making a type-safe value-oriented collection view data source in Swift today.
Conversation
At least it's reusable, unlike most CV / TV data sources. But yeah, dude, I'm with you.
1
Show replies
Replying to
I think you want countElements; it counts random-access collections in O(1) and others in O(N).
1
Oh dang! Lovely.
But what if I want to implement my own collection, for which there's a reasonable O(1) count()? :/
1
Show replies
Although in practice, the CollectionType I'm passing to these things will probably be lazy, which would want ref semantics.
1
2
Show replies
Replying to
Interesting! It's a great solution to the "Swift challenge" we did a few weeks ago @ where I work gist.github.com/Thomvis/db69e0
Replying to
this is great. How would you go about adding a delegate (e.g. delegate:didSomethingWithItem:) to it?
1
Composition; that's another thing.
1
Show replies




