Problem declaring and calling internal metthods

Posted by Martin on Stack Overflow See other posts from Stack Overflow or by Martin
Published on 2011-02-15T23:21:36Z Indexed on 2011/02/15 23:25 UTC
Read the original article Hit count: 256

Filed under:
|

How do I declare and use small helper functions inside my normal methods ?

In on of my objective-c methods I need a function to find an item within a string

-(void) Onlookjson:(id) sender{ NSString * res = getKeyValue(res, @"Birth"); }

I came up with a normal C type declaration for helper function getKeyvalue like this

NSString * getKeyvalue(NSString * s, NSString key){ NSString *trm = [[s substringFromIndex:2] substringToIndex:[s length]-3]; NSArray *list = [trm componentsSeparatedByString:@";"]; .... NSString res; res = [list objectAtIndex:1]; ...

return res; }

Input data string: { Birth = ".."; Death = "..."; ... }

Anyway I get an exception "unrecognized selector sent to instance" for any of the two first lines in the helper function

How do I declare helper functions that are just to be used internally and how to call them safely ?

regards

Martin

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa