On Mar 6, 2017, at 11:36 PM, Rien via swift-users <swift-users@swift.org> wrote:

> On 07 Mar 2017, at 03:56, Edward Connell via swift-users 
> <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:
> 
> I would like to have an Array implementation where I get more information 
> than just "the whole thing changed". 
> As a value type I get it, but lets say it's a list of 500 image info structs 
> and it's bound to UI. You change one item, now the whole array changes and 
> you have to rebuild the entire visual tree right? Rebuilding the state of 
> dependent objects can be really expensive, not just UI things.

In Apple’s Foundation framework, Key-Value Observing (KVO) fills this need, and 
can be used with NSMutableArray, including when it’s bridged to Swift. But it 
doesn’t really transfer to a pure Swift environment since arrays are value 
types: changing one item is actually replacing the entire array with a new one 
(optimized through clever internal data-sharing.)

I would assume that the people working on the design of the Swift Foundation 
library are thinking about similar observer APIs, but I don’t know the details.

—Jens
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to