shah1988
shah1988

Reputation: 2684

When to use a Class having both static methods and instance methods in IPhone

I have created a class which contain only static method in iPhone. The class was mainly to do my core data operations. But suddenly, I had a need to make a method call in a view controller, when an insertion of data in to a table got completed.

At first, I decided to send an NSNotification, once the loop finishes iteration. But then, since I need to use this only for single time, I decided not to go for NSNotificationCenter, instead to use delegation.

Now I have many static method, and two instance methods:

//1
-(id)initWithDelegate:(id)delegate;

//2
-(void)insertContentsInToTheTableFromArray:(NSArray *)contentArray;

Is this a good design pattern, to have both instance methods and class methods in this class. Please share your thoughts.

Upvotes: 1

Views: 133

Answers (1)

Sovannarith
Sovannarith

Reputation: 616

We can use both method in one class. We know that instance methods use an instance of a class, whereas a static method can be used with just the class name. But the static method is a convenience method that use on many foundation classes.

Upvotes: 1

Related Questions