user1127616
user1127616

Reputation:

unrecognized selector sent to class in iPhone

this is my class

#import "Year2011.h"

@implementation Year2011

- (void)Men:(double)speed{
    if (ramspeed <= 180000) {
        cal = 0;
    }

here i have HelloViewController class how can i call Year2011 class and Men mathod. now i tried like this.

@class Year2010;

 IBOutlet Year2010 *Year2010;

calling

double speed=([anualIncome.text doubleValue]);
[Year2010 Men:income];

this one is showing unrecognized selector sent to classerr.guide me i'm new to objective c.

Upvotes: 1

Views: 438

Answers (2)

Till
Till

Reputation: 27597

You are mixing up Class name and Instance name. You also seem to have problems understanding the scope of an instance.

-1- change your instance name to lowercase initial - that is IBOutlet Year2010 *year2010;

-2- change your method names to lowercase initial - that is - (void)men:(double)speed

The compiler currently assumes that Men is a static class method, but you never defined it as such, hence the error.

Upvotes: 3

jscs
jscs

Reputation: 64002

[Year2010 Men:income];

From the code you've shown us, the Year2010 class doesn't have a method Men:. Why would you expect to be able to call it?

Maybe change the type of the variable Year2010 to Year2011?

Also, dear god, don't name your instances the same as your classes. This will be impossible to read and understand when you come back from lunch, let alone months from now.

Upvotes: 4

Related Questions