• 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: some crash i can not explain.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: some crash i can not explain.


  • Subject: Re: some crash i can not explain.
  • From: Sandro Noel <email@hidden>
  • Date: Mon, 23 Oct 2006 15:10:10 -0400

First off, thank you Nick.

I corrected every location where i had made the mistake,
but i still get the runtime error, in this block of code.

-(int)addName:(NSString *)name{
	ADTreeViewItem *item = [[ADTreeViewItem alloc]init];
	[item setDisplayString:name];
	[arrayofNames addObject:item];
	return [arrayOfNames count];
}

I was thinking that the "item" variable was not in a good place, and was released after the function ended,and that might cause problems but then i red up on Array's and they retain objects, so it should not matter where the object is allocated from.
[arrayofNames addObject:item];
this somehow crashes the app without an error message in the NSLog.


Any help on this would be greatly appreciated!
and thank again! learning cocoa this far is fun :)

Sandro Noel.

On 23-Oct-06, at 2:29 PM, Nick Zitzmann wrote:


On Oct 23, 2006, at 12:15 PM, Sandro Noel wrote:

- (oneway void) release{
	[displayString release]; // i have a retain on it.
}

Don't ever do this. Not only does the above not invoke the superclass implementation (it should) but you should override - dealloc instead. In general there are few reasons to override - release, -retain, or -autorelease in subclasses.


-(void)setDisplayString:(NSString *)value{
	// retain the string so it does not go away...
	displayString = [value retain];
}

This will cause a memory leak if displayString was set to something else. Try this instead:


if (value != displayString)
{
	[displayString release];
	displayString = [value retain];
}

Nick Zitzmann
<http://www.chronosnet.com/>






_______________________________________________ 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: some crash i can not explain.
      • From: Andrew Farmer <email@hidden>
    • Re: some crash i can not explain.
      • From: Glenn Zelniker <email@hidden>
References: 
 >some crash i can not explain. (From: Sandro Noel <email@hidden>)
 >Re: some crash i can not explain. (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: floats & Color APIs
  • Next by Date: Re: floats & Color APIs
  • Previous by thread: Re: some crash i can not explain.
  • Next by thread: Re: some crash i can not explain.
  • Index(es):
    • Date
    • Thread