口袋优选

NSNumber+YHExpanded.m 564B

123456789101112131415161718192021222324252627
  1. //
  2. // NSNumber+YHExpanded.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/29.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "NSNumber+YHExpanded.h"
  9. @implementation NSNumber (YHExpanded)
  10. - (NSString *)getStringNumber:(NSInteger)number{
  11. NSString *str=[self stringValue];
  12. if (number==0||str.length>=number) {
  13. return str;
  14. }
  15. NSMutableString *mStr=[NSMutableString stringWithString:str];
  16. for (NSUInteger i=mStr.length; i<number; i++) {
  17. [mStr insertString:@"0" atIndex:0];
  18. }
  19. return mStr;
  20. }
  21. @end