Safe casting for Objective-C