Vladimir Samoilenko Vladimir Samoilenko - 1 year ago 60
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download