Breaking News
Home / iOS / iOS Snippets / How to convert Device ID as NSData to NString in IOS?

How to convert Device ID as NSData to NString in IOS?

Solution

  1.  (NSString *)convertTokenToDeviceID:(NSData *)token
  2. {
  3.  NSMutableString *deviceID = [NSMutableString string];
  4.  // iterate through the bytes and convert to
  5.  hexunsigned char *ptr = (unsigned char *)[token bytes];
  6.  
  7.  for (NSInteger i=0; i < 32; ++i) {
  8.   [deviceID appendString:[NSString stringWithFormat:@"%02x", ptr[i]]];
  9.  }
  10.     return deviceID;
  11. }
[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Advertisment ad adsense adlogger