xref: /aosp_15_r20/external/executorch/backends/apple/coreml/runtime/util/objc_safe_cast.h (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
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)13 inline 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