What exacly the AppDelegates method is given in Xcode??
I have so many classes in my app. Now i want is that i have AudioStreamer class and i have to use that class in most other classes… And I want to have only one instance of AudioStreamer class. So that it will be easy to handle one object.
Is it feasible to declare AudioStreamer class in AppDelegate file and make instance in that file only… Can I access that variable in all the other class.???
What exacly the AppDelegates method is given in Xcode?? I have so many classes
Share
You could use very handy GCD (Grand Central Dispatch) functions to achieve Singleton behavior on these lines –
+ (AudioStreamer*) defaultStreamer { static AudioStreamer* defaultStreamer = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ defaultStreamer = [[AudioStreamer alloc] init]; }); return defaultStreamer; }