0

I am trying to declare a function in my .h file that looks like this:

-(*NSString) encode: (NSString*) unencodedString; 

and I get a syntax error:

expected a type

Here is my .m header for this function:

- (NSString*)encode: (NSString*) unencodedString

and here is how I am trying to call it:

EncodingUtil *encode_object = [[EncodingUtil alloc] init];
NSString *encoded_company_name = [encode_object encode: name];

Could someone please help me understand what I am doing wrong and how to fix it?

Thanks!

4

2 回答 2

3

Your return type says (*NSString). That's completely backwards. You want (NSString*).

于 2012-07-27T21:18:15.790 回答
1

Of course it does (and you should really learn C first, you'll get lost in Obj-C if you don't even know how to declare a pointer type!). What you presumably wanted to write is

- (NSString *)encode:(NSString *)unencodedString; 
于 2012-07-27T21:20:36.043 回答