I want to implement singleten design pattern in iphone code
I have one array. I want it to retain its value between function calls of from single class function.
How Can I use singleten design pattern to do above task? Thanks.
I want to implement singleten design pattern in iphone code
I have one array. I want it to retain its value between function calls of from single class function.
How Can I use singleten design pattern to do above task? Thanks.
better you can initialize it in appdelegate of your project. then you can access this array anywhere in your project.
#define UIAppDelegate ((yourAppDelegate *)[UIApplication sharedApplication].delegate)
include this in your your appDelegate, then you can access your array any where you want.
UIAppDelegate.yourArray
Matt Gallagher has a pretty good writeup, with a very simple to use preprocessor macro to set create a singleton for class:
http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html