Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

file scan results in EX_BAD_ACCESS



Hi All,

I am trying to parse a large file without approximately 300,000 lines of text. Judging from the console print, the method does go through all the records, but then the program seems to freeze with a message "Loading 87348 stack frames", and when I hit cancel to that alert, I get the EX_BAD_ACCESS error. Because of the way the debugger freezes (and because it would take years to load 87000 stack frames), I'm having a terrible time tracing the error.

Critical portions of code below. Thanks for the help.

Daniel

(in main)

	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	DataParser *dp = [DataParser parserWithRecordDelim: @"\r"];
	NSString *path, *fullPath, *fileName;
	NSFileManager *NSFm;
	NSMutableArray *theData;
	
	fileName = @"cleaner data.txt";
	NSFm = [NSFileManager defaultManager];
	path = @"/Users/danielchild/Documents/DATA/";
	fullPath = [path stringByAppendingPathComponent: fileName];
	
	theData = [dp parseFileAtPath: fullPath];
	[pool release];
	
	return 0;

The parser is created as follows:

+ (DataParser *) parserWithRecordDelim: (NSString *) rd
{
  DataParser *dp = [[[DataParser alloc] init] autorelease];
  [dp setRecordDelim: rd];
  return dp;
}

And the parse file method is this:

- (NSMutableArray *) parseFileAtPath: (NSString *) path
{
NSString *fileAsString, *oneRecord;
NSMutableArray *unparsedRecords = [[[NSMutableArray alloc] init] autorelease];


  fileAsString = [NSString stringWithContentsOfFile: path];
  NSScanner *scanner = [NSScanner scannerWithString: fileAsString];
  while (![scanner isAtEnd])
  {
    if ([scanner scanUpToString:recordDelim intoString: &oneRecord])
    {
      [unparsedRecords addObject: oneRecord];
      printf("%s\n", [oneRecord cString]);
    }
  }
  return unparsedRecords;
}

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.