1

I have the following implementation where a comboKey is a string that I am trying to retrieve the integers.

For example if the comboKey is 2m1s and then it returns @[@"2",@"1"]; which is perfect.

If comboKey is 0m2s and then it returns @[@"0",@"2"];, however I do not want to have 0. I only want have positive number(s) @[@"2"];

+ (NSArray*)comboCategoryItems : (NSString*)comboKey
{        
  NSCharacterSet *nonDigitCharacterSet = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
  NSArray *outArray = [comboKey componentsSeparatedByCharactersInSet:nonDigitCharacterSet];
  outArray = [outArray filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"length > 0"]];
  return outArray;
}
4

2 に答える 2