0

I need to create a global object that will work and can be used across all the classes in the program. I've done some research and seen the solution seems to be implementing it in the AppDelegate, but there doesn't seem to be much explanation as to how to accomplish this and more importantly this doesn't really seem correct as per my understand of the AppDelegate purpose.

Flatlyn
  • 2,040
  • 6
  • 40
  • 69

1 Answers1

1

you should check the singleton pattern:

In software engineering, the singleton pattern is a design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects. The term comes from the mathematical concept of a singleton.

here is a source for a example implementation: What should my Objective-C singleton look like?

Community
  • 1
  • 1
CarlJ
  • 9,461
  • 3
  • 33
  • 47
  • but where does that code get implemented? Should it be in AppDelegate? Or is that the object itself. – Flatlyn Jul 23 '12 at 07:37