我感觉很新手。如何计算逗号?我不知道怎么做。我希望代码看起来像这样。
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 = ???;
} 我该怎么做呢?
发布于 2011-10-18 03:32:41
NSString componentsSeparatedByCharactersInSet:或componentsSeparatedByString:,并获取返回的数组大小。
https://stackoverflow.com/questions/7798466
复制相似问题