title: Saving the DeviceToken for Later Use in Apple Push Notification Services
body: <p>In my iPhone app I am getting the device token from Apple which I am assigning a public property inside the Delegate file as shown below: </p>
  
  <pre><code>- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
  {
     self.dToken = [[NSString alloc] initWithData:deviceToken encoding:NSUTF8StringEncoding]; 
  }
  </code></pre>
  
  <p>The dToken property is declared as shown below: </p>
  
  <pre><code>NSString *dToken;
  
  @property (nonatomic,retain) NSString *dToken;
  </code></pre>
  
  <p>But when I try to retrieve the device token from another file I get the null value. </p>
  
  <pre><code>+(NSString *) getDeviceToken
  {
    NSString *deviceToken = [(MyAppDelegate *)[[UIApplication sharedApplication] delegate] dToken];
  
      NSLog(@" getDeviceToken = %@",deviceToken);  // This prints NULL
  
      return deviceToken; 
  
  }
  </code></pre>
  
  <p>What am I doing wrong? </p>