[Solved] How to check symmetric in ios? [closed]


If I’m understanding this, you want to filter out words that are the same if u turn them around like:

lol, radar, rotator?

I’d say make a method like this:

-(BOOL) isSymmetrical(NSString*) string
{
    int maxLength = round([string length] / 2 + 1);
    int frontCharNum = 0;
    int lastCharNum = [string length] - 1;
    NSString frontChar = [string substringWithRange:NSMakeRange(0, 1)];
    NSString lastChar = [string substringWithRange:NSMakeRange(lastCharNum, 1)];
    while(frontChar isEqualToString:lastChar && i < maxLength) {
        frontCharNum++;
        lastCharNum--;
        frontChar = [string substringWithRange:NSMakeRange(frontCharNum, 1)];
        lastChar = [string substringWithRange:NSMakeRange(lastCharNum, 1)];
    }
    if( i < maxLength) {
        return false;
    } else {
        return true;
    }
}

But check out the NSString and change them to how ios handles characters, since using a string like this is sloppy. I haven’t used single characters yet in ios, so I can’t tell the exact format.

solved How to check symmetric in ios? [closed]