ios - NSString from NSData is nil -


I try to get nssting from NSDT, but I get zero value. This is my code:

  NSString * dataString = [[NSString alloc] initWithData: self.message.data encoding: NSUTF8StringEncoding];   

When I login to self.message.data

  self-> _message- & gt; _data: & lt; OS_dispatch_data: data [0x17e48290] = {leaf, size = 331233, buf = 0x3aac000} & gt;   

Does this mean that my data is not zero ?? |

Can anyone help?

Answers to your question in comments: OS_dispatch_data Send_data_t which is toll free bridging with NSDT on iOS 7 and Mavericks. You can just put it on NSData * .

Then, in your case, you can write:

  NSData * datacast = self.message.data; NSString * Data String = [[NSString alloc] initWithData: Datacast encoding: NSUTF8StringEncoding];   

And now you get the right string!

In my case it appeared, when Air Force Networking was inserted from internal NSMutableData to NSDTA .

And this simple artist helps me. As @Daij -Nangan has been mentioned as : if it does not work - then try to check your text encoding Do it. For example, if you are using NSURLSessionTask :

  NSURLSessionTask * function; // Your NSURLSessionTask NSString * Encoding = [[Job Response] textEncodingName];   

In your case ( NSUTF8StringEncoding ) it should be "utf-8" .

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -