• 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: crash when accessing instance variables in class implementation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: crash when accessing instance variables in class implementation


  • Subject: Re: crash when accessing instance variables in class implementation
  • From: Andrew Farmer <email@hidden>
  • Date: Thu, 9 Aug 2007 00:19:40 -0700

On 08 Aug 07, at 23:42, Aleksander Valtyshev wrote:
Hello

I have two classes one is:

Engine.h
- (id) init {
	self = [super init];
	if (self != nil) {
		NSLog(@"Crap OK");
		start_time = [NSDate date];

You need to retain start_time. It's getting autoreleased and probably causing your crash.


If you haven't done so already, review the Cocoa memory management rules. Understanding them is crucial.

-(void) Verlet{
NSLog([[NSNumber numberWithDouble:[start_time timeIntervalSinceNow]] stringValue]);
}

Using variable format strings is dangerous - if the string contains a '%', it'll try to read an argument and probably crash. Use


	NSLog(@"%f", [start_time timeIntervalSinceNow])

instead. This probably isn't causing the problem you're observing, but it's good practice (and simpler, too).
_______________________________________________


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:
This email sent to email@hidden


References: 
 >crash when accessing instance variables in class implementation (From: Aleksander Valtyshev <email@hidden>)

  • Prev by Date: crash when accessing instance variables in class implementation
  • Next by Date: NSTableview crash when it contains more number of records
  • Previous by thread: crash when accessing instance variables in class implementation
  • Next by thread: NSTableview crash when it contains more number of records
  • Index(es):
    • Date
    • Thread