I have this method in my Car.h class file:
@interface Car : NSObject {
NSString * name;
UIImage* image;
}
+ (id)withName:(NSString *)name withImage:(UIImage *)image;
@end
and my Car.m class file:
#import "Car.h"
@implementation Car
@synthesize name, image;
+ (id)withName:(NSString *)name withImage:(UIImage *)image {
Car *newCar = [[[self alloc] init] autorelease];
newCar.name = name;
newCar.image = image;
return newCar;
}
Now I have a MutableArray in a ViewController where I add new Car objects like this:
[myMutableArray addObject:[Car withName:name withImage:image];
But it crashes if image is anything but nil. I can return the name but it doesn't work with anything else but Strings. Could you help me please?