• 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
Re: NSMutable Data Crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutable Data Crash


  • Subject: Re: NSMutable Data Crash
  • From: Bill Bumgarner <email@hidden>
  • Date: Mon, 3 Jul 2006 08:02:09 -0700

On Jul 3, 2006, at 7:42 AM, Aalok wrote:
-(void)makeList1:(NSDictionary*)playlistMap
playlistDetails:(NSDictionary*)detailMap
{
	NSLog(@"**********Entered makeList1**********");
	Byte byteL='L';
	Byte byteN='N';

	NSMutableData *list1 = [[NSMutableData alloc] initWithCapacity:25];
	playlistHeaderList1 = [[NSMutableData alloc] initWithCapacity:25];

playlistHeaderList1 is now allocated and initialized....

playlistMetaDataArray = [[NSMutableArray alloc] init];
finalList1 = [[NSMutableData alloc] init];

unsigned int listCount1;
unsigned int listCount2;

NSString* beoFile=[FAVORITES stringByAppendingString:@".abc"];

NSString* beoFilePathOn=[[NSString alloc] initWithString:volume];
beoFilePathOn=[[[beoFilePathOnBM1 stringByAppendingString:sharedFolder]
stringByAppendingString:systemFolderIn]
stringByAppendingString:beoFile];

(Use the path manipulation API; that way, you don't have to worry about whether or not you have prefixed or suffixed every path element with a '/')


	if(![fileManager fileExistsAtPath:Path])
	{
		NSLog(@"**********beo file doesn't exists**********");
		//Create the file
		[self generateMetaDataFile:beoFile
								GUID:UUID
								command:NET_MUSIC_FAVORITES
								msgKind:@"1"];
		NSLog(@"**********net music file created. file created**********");
		//Read the header contents
		[playlistHeaderList1 initWithContentsOfFile:[tempFileLocation
stringByAppendingString:beoFile]];

Then you re-initialize playlistHeaderList1 here. No object should ever have a designated initializer called twice. At this point, the internal state of playlistHeaderList1 is likely borked.


		NSLog(@"**********Here 1**********");
		[playlistMetaDataArray addObject:playlistHeaderList1];

Which causes this line to crash.

		NSLog(@"**********Here 2**********");
		NSArray *allKeys=[NSArray arrayWithArray:[playlistMap allKeys]];

(Do you really need to create a new array here?)

NSLog(@"**********header list read**********");

And, of course, you are releasing everything you allocated above, right?

b.bum
_______________________________________________
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


References: 
 >NSMutable Data Crash (From: Aalok <email@hidden>)

  • Prev by Date: Re: NSAttributedString behaving badly
  • Next by Date: Re: flipping between tabs in tab view
  • Previous by thread: NSMutable Data Crash
  • Next by thread: Model / View best practice
  • Index(es):
    • Date
    • Thread