[swift-evolution] Custom didSet methods

肇鑫 owenzx at gmail.com
Tue Jan 12 06:33:16 CST 2016


I don't know if this is a good idea. If you insert an item to an array,
what should happen? The items after the inserted item should be considered
as removed or not? They indexes are changed but the values not.

zhaoxin

On Tue, Jan 12, 2016 at 7:24 PM, James Campbell via swift-evolution <
swift-evolution at swift.org> wrote:

> When declaring a collection, it would be nice to have a way of knowing
> when an item is set/added and removed.
>
> For example you could trigger a layer to be added to the layer hiearchy.
>
> var shapeLayers: [CAShapeLayer] {
>
> didAdd(item) {
>  addSubLayer(item)
> }
>
> willRemove(item){
>  item.removeFromSuperlayer()
> }
> }
>
> --
>  Wizard
> james at supmenow.com
> +44 7523 279 698
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>


-- 

Owen Zhao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160112/3dda33f0/attachment.html>


More information about the swift-evolution mailing list