NSString 中带星号的子字符串
嗨,朋友们,我想在表格视图单元格中显示信用卡号码,所以我只想显示最后四个字符,例如 XXXXXXXXXX1111 第一个字符被替换为 x 或其他字符 我该怎么做?帮我
我已经尝试过如下所示,
NSString *CardNumber = [CardNumberValues objectAtIndex:indexPath.row];
NSRange subStringRange = NSMakeRange(0,[CardNumber length]-4);
NSMutableCharacterSet *NumSet = [NSMutableCharacterSet characterSetWithRange:subStringRange];
CardNumber = [[CardNumber componentsSeparatedByCharactersInSet:NumSet] componentsJoinedByString:@"X"];
cell.CardNumber.text = CardNumber;
但它不起作用,你可以建议任何参考或代码吗...
Hi friends i want to display credit card number in table view cell,so i want to display only last four characters like XXXXXXXXXX1111 first charecters is replaced with x or some other character how can i do this can any one help me
i have tried like bellow
NSString *CardNumber = [CardNumberValues objectAtIndex:indexPath.row];
NSRange subStringRange = NSMakeRange(0,[CardNumber length]-4);
NSMutableCharacterSet *NumSet = [NSMutableCharacterSet characterSetWithRange:subStringRange];
CardNumber = [[CardNumber componentsSeparatedByCharactersInSet:NumSet] componentsJoinedByString:@"X"];
cell.CardNumber.text = CardNumber;
but its not working can u suggest any reference or code...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用这个
Use this
我假设卡号是 16 位数字。
I am assuming that card numbers are 16 digits.