1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- //
- // NSString+HXExtension.m
- // HXPhotoPickerExample
- //
- // Created by Silence on 2019/1/10.
- // Copyright © 2019年 Silence. All rights reserved.
- //
- #import "NSString+HXExtension.h"
- @implementation NSString (HXExtension)
- - (NSString *)hx_countStrBecomeComma {
- if (self.length < 3) {
- return self;
- }
- int count = 0;
- long long int a = self.longLongValue;
- while (a != 0) {
- count++;
- a /= 10;
- }
- NSMutableString *string = [NSMutableString stringWithString:self];
- NSMutableString *newstring = [NSMutableString string];
- while (count > 3) {
- count -= 3;
- NSRange rang = NSMakeRange(string.length - 3, 3);
- NSString *str = [string substringWithRange:rang];
- [newstring insertString:str atIndex:0];
- [newstring insertString:@"," atIndex:0];
- [string deleteCharactersInRange:rang];
- }
- [newstring insertString:string atIndex:0];
- return newstring;
- }
- + (NSString *)hx_fileName {
- CFUUIDRef uuid = CFUUIDCreate(nil);
- NSString *uuidString = (__bridge_transfer NSString*)CFUUIDCreateString(nil, uuid);
- CFRelease(uuid);
- NSString *uuidStr = [[uuidString stringByReplacingOccurrencesOfString:@"-" withString:@""] lowercaseString];
- NSString *name = [NSString stringWithFormat:@"%@",uuidStr];
-
- NSString *fileName = @"";
- NSDate *nowDate = [NSDate date];
- NSString *dateStr = [NSString stringWithFormat:@"%ld", (long)[nowDate timeIntervalSince1970]];
- NSString *numStr = [NSString stringWithFormat:@"%d",arc4random()%10000];
- fileName = [fileName stringByAppendingString:@"hx"];
- fileName = [fileName stringByAppendingString:dateStr];
- fileName = [fileName stringByAppendingString:numStr];
-
- return [NSString stringWithFormat:@"%@%@",name,fileName];
- }
- @end
|