0

I have written a singleton class (in objective-C) with methods:

//shared instance
+(void) sharedInstance;

//method to get all feeds.
-(NSArray*)getAllFeedItems;

So to use this I have to call [[MyClass sharedInstance] getAllFeedItems];

Now instead of that if I define a static method:

+(NSArray*)getFeedItems;

which in turn implements:

+(NSArray*)getFeedItems{
  return [[MyClass sharedInstance] getAllFeedItems];
}

So that now I can simply use: [MyClass getFeedItems];. Is there anything wrong in doing so? will it cause any issues or is it bad coding practice? For me it was just making the function Call easier.

Vishal
  • 147
  • 10
  • 1
    This question is "primarily opinion-based". It really depends on your use, if you may authorize at some point not using the singleton, but creating a simple instance... If it's more readable to specify that by writing `[[MyClass sharedInstance] doSomething]`, it reminds that you are using a singleton... – Larme Feb 16 '17 at 16:28
  • 1
    @Larme Since the receiver is a class object, one is reminded. – Amin Negm-Awad Feb 17 '17 at 05:43

0 Answers0