ios银行卡号加入* 并四个一个空格

[ios银行卡号加入* 并四个一个空格]

原文地址:(http://www.cnblogs.com/chaicla-ios/p/6742080.html)

+ (NSString *)getNewBankNumWitOldBankNum:(NSString *)bankNum{
NSMutableString *mutableStr;
if (bankNum.length) {
mutableStr = [NSMutableString stringWithString:bankNum];
for (int i = 0 ; i < mutableStr.length; i ++) {
    if (i>2&&i 0) {
        NSString *subString = [text substringToIndex:MIN(text.length, 4)];
        newString = [newString stringByAppendingString:subString];
        if (subString.length == 4) {
            newString = [newString stringByAppendingString:@" "];
        }
        text = [text substringFromIndex:MIN(text.length, 4)];
    }
    newString = [newString stringByTrimmingCharactersInSet:[characterSet invertedSet]];
return newString;
  }
   return bankNum;
}

你可能感兴趣的:(ios银行卡号加入* 并四个一个空格)