• 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
Release of NSData causes crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Release of NSData causes crash


  • Subject: Release of NSData causes crash
  • From: John Nairn <email@hidden>
  • Date: Tue, 2 May 2006 17:09:54 -0700

The following code inputs an NSData object from a file. Since the file might be large (with potential VM limitations), I tried to release the NSData object once it has been translated into a unicode NSString. A release at the wrong time leads to a crash.

Here is code fragment:

	NSData *gedData=[[NSData alloc] initWithContentsOfFile:path];
	[self setGedcom:gedData];

- (void)setGedcom:(NSData *)gedcom
{
    ged=[[NSString alloc] initWithData:gedcom encoding:encoding];
	[gedcom release];
    [self setRecordsFromString:ged];
}

If I release the gedcom NSData object as above, setRecordsFromString completes but the application soon crashes. If the release is moved to just after setRecordsFromString, it works fine. Furthermore, setRecordsFromString never uses gedcom (and in fact does not even know about it).

It seems like the initWithData creates an NSString that needs the NSData object around. The only reason I am using the NSString is to be able to convert various character sets all into unicode, but I thought once the string was created, the NSData would no longer be needed?

---------------
John Nairn (1-541-737-4265, FAX:1-541-737-3385)
Professor and Richardson Chair
Web Page: http://woodscience.oregonstate.edu/faculty/nairn (under construction)
FEA/MPM Web Page: http://oregonstate.edu/~nairnj




_______________________________________________
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


  • Prev by Date: Re: can't get DOMDocument from WebView
  • Next by Date: Re: Refactoring tools available for Cocoa / ObjC?
  • Previous by thread: Re: address book
  • Next by thread: Re: Release of NSData causes crash
  • Index(es):
    • Date
    • Thread