Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Consider using <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSScanner_Class/" rel="nofollow noreferrer">NSScanner</a>, and specifically the methods <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSScanner_Class/Reference/Reference.html#//apple_ref/occ/instm/NSScanner/setCharactersToBeSkipped:" rel="nofollow noreferrer"><code>-setCharactersToBeSkipped:</code></a> (which accepts an NSCharacterSet) and <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSScanner_Class/Reference/Reference.html#//apple_ref/occ/instm/NSScanner/scanString:intoString:" rel="nofollow noreferrer"><code>-scanString:intoString:</code></a> (which accepts a string and returns the scanned string by reference).</p> <p>You may also want to couple this with <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/localizedCompare:" rel="nofollow noreferrer"><code>-[NSString localizedCompare:]</code></a>, or perhaps <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/compare:options:" rel="nofollow noreferrer"><code>-[NSString compare:options:]</code></a> with the <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/c_ref/NSDiacriticInsensitiveSearch" rel="nofollow noreferrer">NSDiacriticInsensitiveSearch</a> option. That could simplify having to remove/replace accents, so you can focus on removing puncuation, whitespace, etc.</p> <p>If you must use an approach like you presented in your question, at least use an NSMutableString and <code>replaceOccurrencesOfString:withString:options:range:</code> — that will be much more efficient than creating tons of nearly-identical autoreleased strings. It could be that just reducing the number of allocations will boost performance "enough" for the time being.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload