user1377548
user1377548

Reputation: 21

Objective-C Selector Help Needed

I keep on getting the error instance method perform selector not found... Can anyone help me with clearing this error?

#import <Foundation/Foundation.h>
#import "add.h"

int main(int argc, const char * argv[])
{
    SEL mySelector;

    id b = [[add alloc] init];

    mySelector = @selector(add2Num:);

    [b performSelector: mySelector]; // here is where i am getting the error

    [b release];

    return 0;
}

and then int the add.m file

#import "add.h"

@implementation add

-(void)add2Num
{
    num1 = 1;
    num2 = 2;
    iResult = num1+ num2;
}

@end

thanks for your help in advance.

Upvotes: 1

Views: 130

Answers (2)

Jay O&#39;Conor
Jay O&#39;Conor

Reputation: 2495

This looks to be a simple typo. I believe you meant performSelector:, not preformSelector:. Reverse the 'r' and the 'e'.

Upvotes: 0

inspector-g
inspector-g

Reputation: 4176

The issue is likely that you typed @selector(add2Num:) instead of @selector(add2Num).

Notice the ":" missing from the end of the selector name in my corrected syntax. Including the ":" indicates that the selector takes an argument, but your method addNum does not.

Upvotes: 3

Related Questions