ios - Trouble getting device token into global variable -


i trying device token , put device token global variable (or access view). code in appdelgate follows:

- (void)application:(uiapplication*)application didregisterforremotenotificationswithdevicetoken:(nsmutabledata*)devicetoken {     dataclass *obj=[dataclass getinstance];       obj.userdevice = devicetoken;        nslog(@"%@",obj.userdevice);   } 

this displays token. when try access through global variable in view, displays "null". code follows:

 dataclass *obj=[dataclass getinstance];   nslog(@"%@",obj.userdevice); 

any ideas? or solution? want access token view i'm open other suggestions.

edit: dataclass

   static dataclass *instance =nil;     +(dataclass *)getinstance  {     @synchronized(self)     {         if(instance==nil)         {              instance= [dataclass new];         }     }     return instance; } 

i've found answer. involves saving token user defaults.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -