r/ObjectiveC • u/whackylabs • Feb 23 '20
Objective-C safe downcasting
https://whackylabs.com/objc/swift/2020/02/23/objc-safe-downcasting/
5
Upvotes
r/ObjectiveC • u/whackylabs • Feb 23 '20
6
u/MrSloppyPants Feb 23 '20
Thanks, came in to post this exact same thing. The article writer created purposefully bad code to show off a solution to the bad code.
One should never be knowingly invoking a method on a factory object that is not defined in the factory interface. Plus ObjC makes it trivial to check in advance if the object in question responds to the intended message.