NSString+extension.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /********************************************************************************************************
  2. * @file NSString+extension.h
  3. *
  4. * @brief for TLSR chips
  5. *
  6. * @author telink
  7. * @date Sep. 30, 2010
  8. *
  9. * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd.
  10. * All rights reserved.
  11. *
  12. * The information contained herein is confidential and proprietary property of Telink
  13. * Semiconductor (Shanghai) Co., Ltd. and is available under the terms
  14. * of Commercial License Agreement between Telink Semiconductor (Shanghai)
  15. * Co., Ltd. and the licensee in separate contract or the terms described here-in.
  16. * This heading MUST NOT be removed from this file.
  17. *
  18. * Licensees are granted free, non-transferable use of the information in this
  19. * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
  20. *
  21. *******************************************************************************************************/
  22. //
  23. // NSString+extension.h
  24. // SigMeshOCDemo
  25. //
  26. // Created by 梁家誌 on 2018/8/2.
  27. // Copyright © 2018年 Telink. All rights reserved.
  28. //
  29. #import <Foundation/Foundation.h>
  30. @interface NSString (extension)
  31. /*
  32. *去掉首尾空格
  33. */
  34. - (NSString *)removeHeadAndTailSpace;
  35. /*
  36. *去掉首尾空格 包括后面的换行 \n
  37. */
  38. - (NSString *)removeHeadAndTailSpacePro;
  39. /*
  40. *去掉所有空格
  41. */
  42. - (NSString *)removeAllSapce;
  43. /*
  44. *去掉所有空格和最后的回车
  45. */
  46. - (NSString *)removeAllSapceAndNewlines;
  47. /// 去掉所有空格和最后的回车,并在字符串前面补充“0”使其满足长度length
  48. /// @param length 需要返回的字符串的长度,大于该长度直接返回,不在补“0”
  49. - (NSString *)formatToLength:(UInt8)length;
  50. /*
  51. *循环在间隔n个字符添加m个空格
  52. */
  53. - (NSString *)insertSpaceNum:(int)spaceNum charNum:(int)charNum;
  54. ///JSON字符串转化为字典
  55. + (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;
  56. @end