//在.m文件中实现NSString*NSStringFromTransactionState(TransactionState state) {switch(state) {caseTransactionOpened:return@"Opened";caseTransactionPending:return@"Pending";caseTransactionClosed:return@"Closed";default:returnnil; } } 参考资料:http://nshipster.com/c-storage-classes/...
+(NSString*)getTestTypeString:(TestType)t{NSString*result=nil;switch(t){caseTestTypeA:result=@"TypeA";break;caseTestTypeB:result=@"TypeB";break;caseTestTypeC:result=@"TypeC";break;default:result=@"unknown";}returnresult;} 通过定义一个const NSString,可以将转换方法简化如下: NSString*cons...
#define enumToString(value) @#value eg. typedef NS_ENUM(NSInteger, Sex) { Male = 0, Famale = 1, }; NSString * string = enumToString(Male); NSLog@(@&qu
@interface PersonModel : NSObject /** NSString 姓名/@property (nonatomic, copy) NSString name;/NSUInteger 年龄/@property (nonatomic, assign) NSUInteger age;/* ZLPersonSex 性别 */ @property (nonatomic, assign) PersonSex sex; (instancetype)personWithName:(NSString *)name age:(NSUInteger)age...
而且未来type的数量可能会越来越多,所以这个如果用switch,if等来操作判断对应的字符串显然是不合理的,太冗余不利于扩展,采用数据字典的方式也不太好还需要自己手动建,每次更新也要手动修改,最好的方式是我们可以直接通过两个type就组合出对应的string,但是OC中反射只是针对于Class,对于基础类型的操作我们只能依赖于C++...
NSLeftMouseUpMask = 1 << NSLeftMouseUp,NSRightMouseDownMask = 1 << NSRightMouseDown,NSRightMouseUpMask = 1 << NSRightMouseUp,NSMouseMovedMask = 1 << NSMouseMoved,NSLeftMouseDraggedMask = 1 << NSLeftMouseDragged,NSRightMouseDraggedMask = 1 << NSRightMouseDragge...
Macro of Convert Enum to NSString in Objective-c. Contribute to PINKONG/EnumStringConvertible development by creating an account on GitHub.
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 9, 0, ObjCRuntime.PlatformArchitecture.All, null)] [ObjCRuntime.Introduced(ObjCRuntime.PlatformName.MacOSX, 10, 11, ObjCRuntime.PlatformArchitecture.All, null)] public enum NSStringTransform ...
NSMutableAttributedString NSMutableCharacterSet NSMutableCopying NSMutableData NSMutableDictionary NSMutableDictionary<TKey,TValue> NSMutableIndexSet NSMutableOrderedSet NSMutableOrderedSet<TKey> NSMutableSet NSMutableSet<TKey> NSMutableString NSMutableUrlRequest NSNetDomainEventArgs NSNetService NSNetServiceBrowser NSNe...
NSMutableAttributedStringAppKitAddons NSMutableFontCollection NSMutableParagraphStyle NSNib NSObject_NSEditorRegistration NSObject_NSFontPanelValidationAdditions NSObject_NSToolbarItemValidation NSObjectController NSObjectPredicate NSOpenGLContext NSOpenGLContextParameter NSOpenGLGlobalOption NSOpenGLLayer NSOpenGLPixel...