NSString+YYAdd.m 559 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // NSString+YYAdd.m
  3. // Runner
  4. //
  5. // Created by apple on 2021/9/22.
  6. //
  7. #import "NSString+YYAdd.h"
  8. #import "NSData+YYAdd.h"
  9. @implementation NSString (YYAdd)
  10. - (NSData *)dataValue {
  11. return [self dataUsingEncoding:NSUTF8StringEncoding];
  12. }
  13. - (id)jsonValueDecoded {
  14. return [[self dataValue] jsonValueDecoded];
  15. }
  16. - (NSString *)toString :(id)id {
  17. if([id isKindOfClass:[NSString class]]){
  18. return id;
  19. }else if ([id isKindOfClass:[NSNumber class]]){
  20. return [id stringValue];
  21. }
  22. else {
  23. return @"";
  24. }
  25. }
  26. @end