• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
bus error (newbie)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: bus error (newbie)
      • From: Thomas Davie <email@hidden>
    • Re: bus error (newbie)
      • From: Frederick Cheung <email@hidden>
  • Prev by Date: Re: UDP sockets and Cocoa abstractions
  • Next by Date: Re: bus error (newbie)
  • Previous by thread: Re: UDP sockets and Cocoa abstractions
  • Next by thread: Re: bus error (newbie)
  • Index(es):
    • Date
    • Thread