Do not use -> to access instance variables, especially when ivar belongs to another object.
Do it:
_buffer = [[attr string] mutableCopy];
The same goes for this nasty attr->_attributes . Apparently, ZAttributedString exposes attributes` as a property in a private header.
This warning about the compiler seems very optimistic, completely misleading, and most likely completely incorrect in the description. Filing an error so that the explanation is useful.
Please note that @maddy claims that using -> to access instance variables directly in the attr string passed as it acts as a copy constructor is incorrect.
The incoming attr can be an instance of ZAttributedString or an instance of a subclass, or indeed an instance of any class that implements the same interface as ZAttributedString . So you really have to go through accessors to ensure that you are capturing the correct state.
Now, as an implementation detail, ZAttributedString may require that the incoming instance is not a subclass instance of ZAttributedString , but it must use isMemberOfClass: to approve this requirement (and please do not do that).
The only place where direct access to ivar is sometimes used to pull state from another object is to implement copyWithZone: but it is extremely fragile and often leads to violent behavior disruption. In fact, copyWithZone: (outside of the various plist-compatible value classes) is abundant in fragility and the source of many many errors.
source share