I’m new to the hole Xcode/objective-c thing so it would be kind answering my questions in a way I can understand you 🙂
My problem is: I’m trying to create a slot machine with a picker and a button (to spin the wheels of course 😉 ) so I’m implementing 5 images (apple,crown,cherry,lemon,seven,banana) but at the point when I start the app I get this error:
Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[UIImage initWithImage:]: unrecognized selector sent to instance 0x4b649b0’
My code looks like this:
- (void)viewDidLoad {
UIImage *apple = [UIImage imageNamed:@"apple.png"];
UIImage *banana = [UIImage imageNamed:@"banana.png"];
UIImage *cherry = [UIImage imageNamed:@"cherry.png"];
UIImage *crown = [UIImage imageNamed:@"crown.png"];
UIImage *lemon = [UIImage imageNamed:@"lemon.png"];
UIImage *seven = [UIImage imageNamed:@"seven.png"];
for (int i = 1; i <= 5; i++) {
UIImageView *appleView = [[UIImage alloc] initWithImage:apple];
UIImageView *bananaView = [[UIImage alloc] initWithImage:banana];
UIImageView *cherryView = [[UIImage alloc] initWithImage:cherry];
UIImageView *crownView = [[UIImage alloc] initWithImage:crown];
UIImageView *lemonView = [[UIImage alloc] initWithImage:lemon];
UIImageView *sevenView = [[UIImage alloc] initWithImage:seven];
NSArray *imageViewArray = [[NSArray alloc] initWithObjects:appleView, bananaView, cherryView, crownView, lemonView, sevenView, nil];
NSString *fieldName = [[NSString alloc] initWithFormat:@"column%d", i];
[self setValue: imageViewArray forKey:fieldName];
[fieldName release];
[imageViewArray release];
[appleView release];
[bananaView release];
[cherryView release];
[crownView release];
[lemonView release];
[sevenView release];
I’ve been looking around for typos quite some time but didn’t find any. It would be really nice if someone could give me a hint. If the supported code isn’t enough, feel free to ask for more.(Just copied the section where the error occurred) Sorry for my bad english but it’s not my native language 🙂
/edit: I should’ve said, that the original error had been: SIGABRT, but it looks like this error seems to mean a lot without any context 🙂
You need to create your image views with
NOT