bus error (newbie)
bus error (newbie)
- Subject: bus error (newbie)
- From: Daniel Child <email@hidden>
- Date: Mon, 07 Feb 2005 23:56:40 -1000
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];
count++;
}
If I remove
stringForObjectValue, I get a message to the effect that I am passing pointers from incompatible types (presumably because the array (
threeSyllables) contains objects and I need NSStrings to meet the init requirements for
theSyllable.
I know I am missing something incredibly obvious with respect to ways to convert object -> NSString, but after mucking around for a while, I still don't get it. Would appreciate the help!
Thanks,
Daniel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden