//在头文件中声明 typedef NS_ENUM(NSUInteger, TransactionState) { TransactionOpened, TransactionPending, TransactionClosed, }; extern NSString * NSStringFromTransactionState(TransactionState state);
//在.m文件中实现 NSString * NSStringFromTransactionState(TransactionState state) { switch (state) { case TransactionOpened: return @"Opened"; case TransactionPending: return @"Pending"; case TransactionClosed: return @"Closed"; default: return nil; } }
参考资料:http://nshipster.com/c-storage-classes/
时间: 2024-10-12 13:05:16