Strong Like Bull
Strong Like Bull

Reputation: 11317

Why use a singleton to share data between multiple view controllers when you can use NSUserDefaults?

Any thoughts on this ?

Thanks for shedding some light on this.

Upvotes: 0

Views: 210

Answers (1)

user745098
user745098

Reputation:

NSUserDefaults is ready made database provided to us. If we use it, we are saving things in database and making fetch operation.

If you want your data to be persistent then use NSUserDefaults and/or your own database.

If you want to share data globally and dont want it to be persistent then use singleton class.

It is based on our requirement if we want a shared class (singleton class) or a database (NSuserDefaults).

Upvotes: 1

Related Questions