Suppose you have a property with copy semantics. What should you do in the setter if the copy method fails? (I presume this is a possibility, since a copy usually starts with an alloc/init combo, which can fail and return nil.) Apple recommends returning error codes rather than using exceptions, but a setter generally has a void return type. What is the recommended approach? How do you signal that an error has occurred?
Share
There is no way to signal an error, other than that the property whose setter you called would be
nil. You can check fornilafter executing the setter, just as you would to confirm success after alloc/init’ing a new instance.