ApplicationDelegate Singleton iphone
I use a singleton to share an array between several classes and this array holds some info from a xml file.
I have a currencyView
(and when I scroll, new currencyview
is created). When the first CurrView
is loaded, and it happens when the application starts, try to pass data to it but no data is showed on first CurrencyView
, however, when I scroll to the next view, everything is ok.
I have an idea that maybe I tr开发者_StackOverflow中文版y to access a singleton (for first view) before my mainwindow.xib file is all loaded, please help.
Yup you need to create the singleton instance on startup. However if you use the code from this link you can directly access the singleton variable created using a getter method and it can be created at any point and will remain till you dealloc or kill the app.
精彩评论