|
|
#1 |
|
GameCenter question
I have a navigation-type app where you start with a root viewController, and other views get pushed
onto the stack. Question is, if my app uses Game Center in more than one view, should I allocate my GameCenter manager as a singleton, so I can access it from everywhere, or should I allocate a new instance per view? The problem I have with using a singleton, is that my GameCenter manager requires that I setup a delegate. But, only one view can be set as its delegate. So, if I were to use it with multiple views, it would mean I would have to change the delegate everytime I change the view. Is this safe to do? Does it follow any kind of design practice? Last edited by lastcall; Jan 22, 2013 at 08:27 PM. |
|
|
|
0
|
|
|
#2 |
|
If you have a navigation controller that pushes views that all use Game Center, you could have the class that creates the Navigation Controller be the delegate. In this case I assume the app delegate. You could then use the call back in the app delegate to grab the navigation controllers current view controller that would allow you handle events in that class alone. Therefore you would only set the delegate once and which ever view you were on would get the forwarded event form the app delegate.
__________________
2.4 MacBook Aluminum 480GB SSD/750GB Optibay 8GB RAM CE | MacBook 2.4 SR 4GB, 320GB HD | PB G4 1.67 | 15 TiBook-DVI 800 iPhone 4S 16GB | iPhone 5 32GB
|
|
|
|
0
|
|
|
#3 | |
|
Quote:
How do I determine what is the active view controller from the app delegate? |
||
|
|
0
|
|
|
#4 |
|
Found something I can use:
self.navigationController.topViewController |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 01:30 PM.








Linear Mode
