Upvote:2

Aprove answer
NSString *prefix = @"abc"; // adjust the prefix as needed
NSUInteger max = 0;

for (NSString *filename in myArray) {

    // if the prefix matches...
    if (filename.length >= prefix.length && [[filename substringToIndex:prefix.length] isEqualToString:prefix]) {

        // take away every character that's not a number
        NSString *numberAsString = [[filename componentsSeparatedByCharactersInSet:
                [[NSCharacterSet decimalDigitCharacterSet] invertedSet]] 
                componentsJoinedByString:@""];

        // turn the NSString into an int
        NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
        [f setNumberStyle:NSNumberFormatterDecimalStyle];
        int n = [[f numberFromString:numberAsString] integerValue];

        // update the maximum value if necessary
        if (n > max) max = n;

    }
}

Credit Goes to: stackoverflow.com

Related question with same questions but different answers