Bronze Challenge Solution: Finding the Subforum


Created a property for the subforum in RSSItem.h:

In RSSItem.h in parser:didStartElement:namespaceURI:qualifiedName:attributes:

if ([elementName isEqual:@"title"]) { currentString = [[NSMutableString alloc] init]; [self setTitle:currentString]; [self setSubforum:currentString];
In RSSChannel.m inside trimItemTitles, added a regex capture group for the subforum:

NSRegularExpression *regSubforum = [[NSRegularExpression alloc] initWithPattern:@"(.*) :: .* :: .*" options:0 error:nil];
Then inside the for loop:

NSArray *subforumMatches = [regSubforum matchesInString:itemTitle options:0 range:NSMakeRange(0, [itemTitle length])];

if ([subforumMatches count] > 0) { NSTextCheckingResult *subforumResult = [subforumMatches objectAtIndex:0]; if ([subforumResult numberOfRanges] == 2) { NSRange subforumRange = [subforumResult rangeAtIndex:1]; [i setSubforum:[itemTitle substringWithRange:subforumRange]]; } }
In ListViewController.m, changed the cell style to UITableViewCellStyleSubtitle to enable the detailTextLabel to be shown:

Set the text of the detailTextLabel:


A single regex with two capture groups can be used to match both the title and forum from the extended title string.

NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:@"(.*) :: (.*) :: .*" options:0 error:nil];

Forum name can be extracted using [result rangeAtIndex:1], and title will now be at [result rangeAtIndex:2]