crash when accessing instance variables in class implementation
crash when accessing instance variables in class implementation
- Subject: crash when accessing instance variables in class implementation
- From: Aleksander Valtyshev <email@hidden>
- Date: Thu, 9 Aug 2007 09:42:47 +0300
Hello
I have two classes one is:
Engine.h
#import <Cocoa/Cocoa.h>
@interface Engine : NSObject {
NSDate *start_time;
NSTimer *timer;
}
-(id) init;
-(void) dealloc;
-(void) Verlet;
-(void) AccumulateForces;
-(void) SatisfyConstraints;
-(void) TimeStep;
@end
Engine.m
#import "Engine.h"
@implementation Engine
- (id) init {
self = [super init];
if (self != nil) {
NSLog(@"Crap OK");
start_time = [NSDate date];
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self
selector:@selector(TimeStep) userInfo:nil repeats:YES];
}
return self;
}
- (void) dealloc {
[super dealloc];
}
-(void) Verlet{
NSLog([[NSNumber numberWithDouble:[start_time timeIntervalSinceNow]]
stringValue]);
}
-(void) TimeStep{
[self Verlet];
}
-(void) SatisfyConstraints{
}
-(void) AccumulateForces{
}
@end
And other class has Engine *engine reference, and it initializes
engine in awakeFromNib, like this
-(void) awakeFromNib{
engine = [[Engine alloc] init];
if (engine != nil) {
NSLog(@"engine OK");
}
z = -3.0f;
time = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self
selector:@selector(drawFrame) userInfo:nil repeats:YES];
}
The problem is that when ever (in Engine.m) any method accesses
instance variable, program crashes, I'm stuck. Please help, there
must be something obvious I'm doing wrong.
Here is screenshot of what gdm gives:
http://img478.imageshack.us/img478/4429/picture1pt8.png
_______________________________________________
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