我感觉菜鸟 如何计算逗号?我不知道该怎么做。我想要看起来像这样的代码。
Label.text = 找到 4 个逗号!!
NSString *str = @"100,000,000,000,000";
NSRange detecting = [str rangeOfString:@","];
if (detecting .length > 0 ) {
// Count how many commas?
// label.text = ???;
}
Label.text = 找到 3 个逗号!!
NSString *str = @"100,000,000,000";
NSRange detecting = [str rangeOfString:@","];
if (detecting .length > 0 ) {
// Count how many commas?
// label.text = ???;
}
label.text = 找到 1 个逗号!!
NSString *str = @"100,000";
NSRange detecting = [str rangeOfString:@","];
if (detecting .length > 0 ) {
// Count how many commas?
// label.text = ???;
}
输入 noobie 文本框 ["343,433,463"] 我应该有 2 个逗号。
NSString *str = noobie.text;
NSRange detecting = [str rangeOfString:@","];
if (detecting .length > 0 ) {
// Count how many commas?
// label.text = ???;
}
我该怎么做?