开发者

text field with format xx/xx/xx

开发者 https://www.devze.com 2023-03-05 03:29 出处:网络
开发者_JAVA技巧i\'ve a text field and the format must xx/xx/xx. xx it\'s a number from 1 to 9 and each number correspond to a different type of runway contamination for the 1/3,2/3and 3/3 of it\'s len
开发者_JAVA技巧

i've a text field and the format must xx/xx/xx. xx it's a number from 1 to 9 and each number correspond to a different type of runway contamination for the 1/3,2/3 and 3/3 of it's lenght. (i.e. 1 dry, 2 wet, 3 snow).I can also have 2 digit (ie 32) in which case it means that it's snow over wet. I want to get this number from the text field, convert it into plain text and set a label but I don't know how to get rid of the slashes when I get the string.... any idea?


You can use -stringByReplacingOccurrencesOfString:withString::

NSString *trimmedString = [textFieldString
       stringByReplacingOccurrencesOfString:@"/" withString:@""];

Or, if you want to break it up into 3 parts:

NSArray *components = [textFieldString
                     componentsSeparatedByString:@"/"];
for (NSString *component in components) {


}
0

精彩评论

暂无评论...
验证码 换一张
取 消