본문 바로가기

IT/iOs

iOS13(xcode11) NSData 변경사항

xcod11로 빌드시 NSData문제

 

IOS13 적용하다보니 회원정보 encoding 과정에서 NSData 의 description 메소드로 값을 가져오는데 암호화가 안되서

확인해보니 description에서 가져오는 데이터가 틀립니다.

알고보니 아래처럼 xcode11로 빌드를 하면 NSData포맷이 달라져서 앞부분에 length와 bytes정보가 붙습니다.

 

 

 

iOS 13 changes the format of descriptions for Foundation objects, including NSData:

iOS 12 (deviceToken as NSData).description   // "<965b251c 6cb1926d e3cb366f dfb16ddd e6b9086a 8a3cac9e 5f857679 376eab7C>" 

iOS 13 (deviceToken as NSData).description // "{length = 32, bytes = 0x965b251c 6cb1926d e3cb366f dfb16ddd ... 5f857679 376eab7c }"

 

 

 

 

 

description을 debugDescription으로 대치하면 기존과 같이 나옵니다.

iOS 13 (deviceToken as NSData).debugDescription // "<965b251c 6cb1926d e3cb366f dfb16ddd e6b9086a 8a3cac9e 5f857679 376eab7C>" 

 

 

 

 

아래는 애플 개발자 포럼에 해당 내용입니다.

https://forums.developer.apple.com/thread/119111

 

NSData description and NSString stringWithForma... |Apple Developer Forums

Format specifier %@ (in stringWithFormat), by definition, uses the "description" method on the object to get the text to insert, so both of your techniques are basically the same. Using "description" for getting your token as a string was *always* the wron

forums.developer.apple.com

 

 

 

다른 방법으로 NSData+Conversion.h  및 m파일 적용하여 값 변경했다는 내용입니다.

https://stackoverflow.com/questions/1305225/best-way-to-serialize-an-nsdata-into-a-hexadeximal-string

 

Best way to serialize an NSData into a hexadeximal string

I am looking for a nice-cocoa way to serialize an NSData object into a hexadecimal string. The idea is to serialize the deviceToken used for notification before sending it to my server. I have the

stackoverflow.com

 

 

 

https://nshipster.com/apns-device-tokens/

 

Apple Push Notification Device Tokens

Precedent plays an important role throughout software engineering. So what does a change in iOS 13 to push notification registration have to say about Apple’s API design decisions?

nshipster.com

 

ios13 이슈 ios13 nsdata issue ios13 nsdata to string ios13 nsdata to hex string nsdata description push token