Search code examples
iphoneobjective-cios4public-method

Calling a public method


I'm trying to figure out how to centralize a method that I use in a few of my ViewControllers. I already had a singleton that I was using for some variables. I called the singleton class Shared.

I moved my method to the Shared class and tried calling it like so:

m.createdAt = [Shared getUTCFormateDate:[messageObject objectForKey:@"created_at"]];

It's giving me an exception saying that the selector doesn't exist when it tries to call it.

I have already imported Shared.h. Any other thoughts would be appreciated.


Solution

  • If your class is named "Shared" then it looks like you are trying to call a class method rather than an instance method. So, you need to declare the method with + instead of -.