cocoa: NSString not removing all the characters -
I have an integer and for some reason it is not working after 16 or more. Here's my code:
NSArray * sortedArray; Sorted array = [no other is sorted. Use Usage Function: First Numerical Reference: NULL]; Int count2 = [classified array count]; // NSLog (@ "% d", count2); Int z = 0; While (z & lt; count2) {NSString * myString = [sorted array objectuitux: z]; NSString * intstring = [NSString stringWithFormat: @ "% d", z]; NSString * stringwidthspace; StringWithoutSpaces = [[[mystring stringByReplacingOccurrencesOfString: intstring with string: @ ""] mutableCopy]; [Hopeless add object: stringWithoutSpaces]; NSLog (@ "% @", [Ashapoor ObjectOutIndex: Zed]); Z ++; }
Edit: This is not int, this string is the row without the Spaces ... I can not understand what is the reason for it.
"Whichever"
"
"
etc.
I am concerned that this is related to your first question, and that you can move the leading number and the white space from an array Trying to strip what looks like you in that question:
"0 is an object here" "1 what a cat, here's another!" "2 We put here also 2 Give it! "" 3 Let's put this one here "" 4 There is another thing here "
Without knowing the full input, I thought your code is failing because the major number and value are going out of the z
sync because you really do not care what the key number is and Just want to touch it, I recommend a different approach that scans for the main points and from the place comes the extraction where those points end:
NSArray * Array = [NSArray arra YWithObjects: @ "1 one", @ "2 two", @ "5 five", @ "17 seventeen", zero]; NSMutableArray * Result = [NSMutableArray array]; NSScanner * scanner; NSCharacterSet * whitespace = [NSCRactSet WhysespaceClarkets]; (For array in NSString * items) {Scanner = [NSScanner scannerWithString: item]; [Scanner ScannerEventer: NULL]; // Throwing the returning return value ... // If the string does not start with a number, // scan location is 0, which is good [result addObject: [[Item savedFindindex: [scanner scan location]] stringbittramingcarsourceSat: whitespace]]; } NSLog (@ "Result array is:% @", result); // is the result array: (// one, // two, // five, // seventeen //)
)
Comments
Post a Comment