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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -