1 // 2 // objc_safe_cast.h 3 // util 4 // 5 // Copyright © 2024 Apple Inc. All rights reserved. 6 // 7 // Please refer to the license found in the LICENSE file in the root directory of the source tree. 8 9 #pragma once 10 11 #import <Foundation/Foundation.h> 12 check_class(id obj,Class cls)13inline id check_class(id obj, Class cls) { return [obj isKindOfClass:cls] ? obj : nil; } 14 15 #define SAFE_CAST(Object, Type) ((Type*)check_class(Object, [Type class])) 16