Hi,
I am trying to parse a file and place it into an array of objects. The object in question "Syllable" has three string fields.
When I do this, I get a bus error.
int count = 0;
NSMutableArray *syllables;
Syllable *theSyllable;
NSString *line;
NSString *fileContents = [NSString stringWithContentsOfFile:
[@"~/Desktop/wgbppy.txt" stringByExpandingTildeInPath]];
NSArray *linesOfData = [fileContents componentsSeparatedByString:@"\n"];
NSEnumerator *arrayEnum = [linesOfData objectEnumerator];
while (line = [arrayEnum nextObject]) { // for each line of data
// get the three syllables and place it into array
// now parse the syllables so they can be placed in Syllable fields
NSArray *threeSyllables = [line componentsSeparatedByString:@"\t"];
// BUS ERROR OCCURS WHEN I TRY TO INIT THE OBJECT BELOW
[theSyllable initWithPinyin: [threeSyllables[2] stringForObjectValue]
bopomofo: [threeSyllables[1] stringForObjectValue]
wadegiles: [threeSyllables[0] stringForObjectValue]];
[syllables addObject: theSyllable];