¡@

Home 

2014/10/15 ¤U¤È 10:14:33

iphone Programming Glossary: strippedstring

Remove all but numbers from NSString

http://stackoverflow.com/questions/1129521/remove-all-but-numbers-from-nsstring

class you're after is called NSScanner . It's used as follows NSString originalString @ 123 123123 abc NSMutableString strippedString NSMutableString stringWithCapacity originalString.length NSScanner scanner NSScanner scannerWithString originalString NSCharacterSet.. @ 0123456789 while scanner isAtEnd NO NSString buffer if scanner scanCharactersFromSet numbers intoString buffer strippedString appendString buffer else scanner setScanLocation scanner scanLocation 1 NSLog @ @ strippedString 123123123 EDIT I've updated.. intoString buffer strippedString appendString buffer else scanner setScanLocation scanner scanLocation 1 NSLog @ @ strippedString 123123123 EDIT I've updated the code because the original was written off the top of my head and I figured it would be enough..

iPhone rangeOfString

http://stackoverflow.com/questions/5425812/iphone-rangeofstring

. The issue is that when I use rangeOfString to get the accesskey it stops only to the first one This is my code if strippedString rangeOfString @ ACCESSKEY .location NSNotFound NSUInteger int1 strippedString rangeOfString @ ACCESSKEY .location NSString.. only to the first one This is my code if strippedString rangeOfString @ ACCESSKEY .location NSNotFound NSUInteger int1 strippedString rangeOfString @ ACCESSKEY .location NSString finssid strippedString substringWithRange NSMakeRange int1 11 10 NSLog @ Output.. @ ACCESSKEY .location NSNotFound NSUInteger int1 strippedString rangeOfString @ ACCESSKEY .location NSString finssid strippedString substringWithRange NSMakeRange int1 11 10 NSLog @ Output Found it d n int1 NSLog @ Output @ n n finssid What I am doing..