Cannot call a class method with [self theMethod:] Cannot call a class method with [self theMethod:] objective-c objective-c

Cannot call a class method with [self theMethod:]


You should call it like this:

[LoginViewController md5Hash:@"Test"];

Because it's a class (LoginViewController) method and not an instance (self) method.


Or you could do:

- (IBAction) login: (id) sender {        //Call the static method        [[self class] md5Hash:@"Test"];}

which should be exactly the same as calling [LoginViewController md5Hash:@"Test"] directly with the class name. Remember that md5Hash is a CLASS method, not an instance one, so you can't call it in objects (instances of the class), but from the class itself.


you call static methods on the class, and not on the instance. So should be

- (IBAction) login: (id) sender {        //Call the static method        [LoginViewController md5Hash:@"Test"];}