Parsing and pattern matching in Objective-C