Problem with class methods in objective c

Posted by Rajashekar on Stack Overflow See other posts from Stack Overflow or by Rajashekar
Published on 2011-02-11T07:14:33Z Indexed on 2011/02/11 7:25 UTC
Read the original article Hit count: 114

Filed under:
|

Hi Guys

i have a tableview controller like so,

NSString *selectedindex;

@interface ContactsController : UITableViewController { NSMutableArray *names; NSMutableArray *phonenumbers; NSMutableArray *contacts; DatabaseCRUD *sampledatabase;
} +(NSString *) returnselectedindex; @end

in the implementation file i have

+(NSString *) returnselectedindex { return selectedindex; } when a row is selected in the tableview i put have the following code.

selectedindex = [NSString stringWithFormat:@"%d", indexPath.row];
NSLog(@"selected row is %@",selectedindex);

in a different class i am trying to access the selectedindex. like so

selected = [ContactsController returnselectedindex]; NSLog(@"selected is %@",selected);

it gives me a warning: 'ContactsController' may not respond to '+returnselectedindex'

and crashes. i am not sure why. i have used class methods previously lot of times , and never had a problem. any help please. Thank You.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c