December 2018
Intermediate to advanced
414 pages
10h 19m
English
With our ability to generate both NSCopying conformance and the Mutable counterpart of objects, it is possible to generate an NSMutableCopying counterpart automatically. NSMutableCopying is a convenience method that returns an instance of an object known to have mutable members.
Create your stencil as follows:
{% for type in types.implementing.AutoMutableCopy %}extension {{ type.name }}: NSMutableCopying { func mutableCopy(with zone: NSZone? = nil) -> Any { return Mutable{{type.name}}( {% map type.variables into vars using var %} {{ var.name }}: {{ var.name }}{% endmap %} {{ vars|join:"," }}) }}{% endfor %}
This stencil is very similar to the one used to generate the NSCopying protocol conformance. ...
Read now
Unlock full access