Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert NSTaggedPointerString to NSString

Tags:

I had called an interface of Baidu to check id Number, however the value of Sex returned with sex = M, without "" around the M in JSON, when I use NSString in module to store it and then print the class name of this sex property, it printed as NSTaggedPointerString, I doubt how to convert it to a String to use it. Anyone have good ideas?

like image 339
Henry Zhang Avatar asked Oct 19 '15 05:10

Henry Zhang


People also ask

What is NSTaggedPointerString?

NSTaggedPointerString is about the dynamic type of the object. Your issue is about the type you have written in your source code. – Catfish_Man. Apr 6, 2016 at 17:16. 1.

What is NSString?

A static, plain-text Unicode string object that bridges to String ; use NSString when you need reference semantics or other Foundation-specific behavior.


2 Answers

NSTaggedPointerString is already an NSString, it's just a subclass. You can use it anywhere you can use an NSString, without conversion.

like image 52
Catfish_Man Avatar answered Sep 28 '22 08:09

Catfish_Man


I have encountered places where NSTaggedPointerString cannot be used as a NSString, such as when creating an NSDictionary. In those cases use stringWithString::

NSString* <# myNSString #> = [NSString stringWithString:<# myNSTaggegedString #>]; 
like image 33
Stan James Avatar answered Sep 28 '22 07:09

Stan James