Vladimir Samoilenko Vladimir Samoilenko - 1 month ago 4x
Objective-C Question

Can i get another object from class method?

So, i want to get NSDictionary from class method, i think it will be like this:

NSDictionary *dictionary = [SomeClass parseJSONAndGetDictionary];

Can someone explain me how i can make it?


in you .h file of your SomeClass declare method like,

  + (NSDictionary*)aClassMethod;

and in your .m file of your SomeClass implement it like it will return NSDictionary something like,

  + (NSDictionary*)population{ 

       // get desired dictionary here and return it

      return dictionary ;

the you can got dictionary from any class like,

 NSDictionary *dictionary = [SomeClass parseJSONAndGetDictionary];

by implementing SomeClass.h file in that class.