Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conflicting parameter types in implementation of 'Login:': '__strong id' vs '__strong Callback' (aka 'void (^__strong)(RESTResponse *__strong)')

very fresh to objective C, cant figure out what i am missing.

.h file

#import <Foundation/Foundation.h>
#import "RESTResponse.h"
typedef void (^Callback)(RESTResponse*);

@interface AquaUser : NSObject

....

-(void)Login:Callback;
-(void)Register:Callback;


@end

.m file

-(void)Login:(Callback) handler
{
...
 RESTResponse *result = [RESTResponse new];
         result.sucesss = true  ;
         result.response = @"Login succesfull";
         handler(result);
...
}

in .m i get warning on the declaration of Login and register Conflicting parameter types in implementation of 'Login:': '_strong id' vs '_strong Callback' (aka 'void (^_strong)(RESTResponse *_strong)')

although code compile and work, i am tryinf to learn the lesson here. help appreciated.

like image 222
Daniel S. Avatar asked Dec 02 '22 20:12

Daniel S.


2 Answers

Looks like you are missing the types in your .h file.

@interface AquaUser : NSObject

....

-(void)Login:(Callback)handler;
-(void)Register:(Callback)handler;


@end

Edit:

Just a side note, in objective c, it's best to make your methods start with a lower case character. Not a big deal but it's common practice.

like image 155
Lance Avatar answered Dec 30 '22 06:12

Lance


Happens also if you don't #import class that is declaring used Type in your .h file and use @class instead. @class doesn't work in this case. I had an enum defined in class I only mentioned with @class and wrote function that uses that enum in .h of my other class. Switching to #import worked.

like image 28
jovanjovanovic Avatar answered Dec 30 '22 07:12

jovanjovanovic