Quickies

[categories] [index] [all (527)] [latest]

Cocoa Foundation
  1. - (NSString *)stringWithoutComments:(NSString *)string {
        NSArray *inputLines = [string componentsSeparatedByString:@"\n"];
        NSPredicate *commentsPredicate = [NSPredicate predicateWithFormat: @"SELF beginswith %@", @"--"];
        NSPredicate *notCommentsPredicate = [NSCompoundPredicate notPredicateWithSubpredicate:commentsPredicate];
        NSArray *filteredLines = [inputLines filteredArrayUsingPredicate:notCommentsPredicate];
        return [filteredLines componentsJoinedByString:@"\n"];
    }