Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After a while (a day) working on the code above, I finally get it through. But don't know about the performance. Someone comment and help me improve about performance, please. Thanks.</p> <pre><code>- (BOOL) test:(NSString*)aString include:(NSString*) keyWord doTrim:(BOOL)doTrim { // break recursion. if([aString length] &lt; [keyWord length]) return false; // First, loop through each keyword's character for (NSUInteger i = 0; i &lt; [keyWord length]; i++) { // Get @"aA@∂", @"bBß", @"c©C&lt;(" or only the character itself. // like, if the keyword's character is A, return the string @"aA@∂". // If the character is not in the variants set, eg. P, return @"P" NSString* c = [NSString stringWithFormat:@"%C", [keyWord characterAtIndex:i]]; NSString *rs = [self variantsWithChar:c]; NSString *theTargetChar = [NSString stringWithFormat:@"%C", [aString characterAtIndex:i]]; // Check if rs (@"aA@∂" or @"P") contains aString[i] character if([rs rangeOfString:theTargetChar].location == NSNotFound) { // If not the same char, remove first char in targetString (aString), recursion to match again. return [self test:[aString substringFromIndex:1] include:keyWord doTrim:NO]; } } // If all match with keyword, return true. return true; } </code></pre> <p>If you remove all comment, it'll be pretty short...</p> <p>////////////////////////////////////////</p> <pre><code>- (NSString *) variantsWithChar:(NSString *) c{ for (NSString *s in self.variants) { if ([s rangeOfString:c].location != NSNotFound) { return s; } } return c; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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