I have this interface:
#import <Foundation/Foundation.h>
@interface Cards : NSObject { NSString* effect; NSString* image; }
-(NSString*) effect;
-(NSString*) image;
-(void) setEffect: (NSString*) effect2;
-(void) setImage: (NSString*) image2;
@end
And this implementation:
#import "Cards.h"
@implementation Cards
-(NSString*) effect
{
return [effect autorelease];
}
-(NSString*) image
{
return [image autorelease];
}
-(void) setEffect: (NSString*) effect2
{
effect = [[NSString alloc]initWithString:effect2];
}
-(void) setImage: (NSString*) image2
{
image = [[NSString alloc]initWithString:@""];
}
-(void) dealloc
{
[effect release];
[image release];
[super dealloc];
}
@end
Now if I make a Cards object such as Cards* card and then I run the metod setEffect like so: [card setEffect:@""]; It compiles but gives me a runtime error. Anyone know why? Thanks in advance!