Hi,
I am a newbie, writing a simple program and while there are no warnings/errors during compilation. I am getting a "EXC_BAD_ACCESS" error. Will appreciate any help with this:
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
moviedatabase *movie1=[[moviedatabase alloc] init];
[movie1 addMovieWithName:@"DDLJ" andyear:1789 andlength:360 andGenre:Horror];
[movie1 printAll];
[movie1 release];
[pool drain];
return 0;
}
Here is the moviesdatabase class and movies class which it is inheriting:
@interface moviedatabase : movies{
//no variables in the class
}
-(void) addMovieWithName: (NSString *)mname andyear: (int) myear andlength: (int) mlength andGenre: (enum Genre) mgenre;
-(void) printAll;
@end
@interface movies : NSObject {
NSString *name;
int year;
int length;
enum Genre {Comedy,Drama,Horror,Action} genre;
}
@property (nonatomic) NSString *name;
@property (nonatomic) int year;
@property (nonatomic) int length;
@property (nonatomic) enum Genre genre;
-(id) initWithName: (NSString *)name andyear: (int) year andlength: (int) length andGenre: (enum Genre) genre;
@end
Including the implementation of moviedatabase:
#import "moviedatabase.h"
@implementation moviedatabase
-(void) addMovieWithName: (NSString *) mname andyear: (int) myear andlength: (int) mlength andGenre: (enum Genre) mgenre
{
name=mname;
year=myear;
length=mlength;
genre=mgenre;
}
-(void) printAll;
{
NSLog(@"name=%@, year=%@, length=%@, genre=%@",name,year,length,genre);
}
@end