Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9258835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:30:29+00:00 2026-06-18T12:30:29+00:00

I got from server a response : [NSURLConnection sendAsynchronousRequest:request queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response,

  • 0

I got from server a response :

 [NSURLConnection
     sendAsynchronousRequest:request
     queue:[[NSOperationQueue alloc] init]
     completionHandler:^(NSURLResponse *response,
                         NSData *data,
                         NSError *error)
     {

         if ([data length] >0 && error == nil)
         {
             NSLog(@"DATA1: %@",data);
             NSString *content;
             content = [NSString stringWithUTF8String:[data bytes]];
             NSLog(@"DATA2: %@",content);

something is strange here. the second NSLOG shows me a null data- but if the data is null how could he pass the if statement ?
the first log show me: <636f6e66 69726d65 64> .

I have to say that sometimes it do work ! it depend on the values somehow …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:30:30+00:00Added an answer on June 18, 2026 at 12:30 pm

    Because the with first log, you’re printing the NSData instance, and with the second, the NSString you want to generate from the data. But if the data is not valid UTF-8 (which may be the case, since it’s not NUL-terminated, and stringWithUTF8String: requires a NUL-terminated string, so it doesn’t stop at the end and it might read garbage), then it returns nil.

    What you want is:

    content = [[[NSString alloc] initWithBytes:data.bytes length:data.length encoding:NSUTF8StringEncoding] autorelease];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The JSON response we got from the server is already stringfied or we need
With this function I got a String from the server as a response: String
I have got the response from server which I have stored in the list.I
I got JSON response from server parsing json response i got content which contains
How could we handle null for a datetime field (got from SQL Server) in
I've checked the connection string (I got it from the server explorer). I've checked
I need to set time in my app. I got time stamp from server
I got this cookie returned from web-server in Set-Cookie header: PHPSESSID=462rutd8g0sbg9sinh3hqa2ol6; path=/,wordpress_test_cookie=WP+Cookie+check; path=/,wordpress_ca07030412dd7fcd4dbeaae0bd9f5df9=testemail@example.com; expires=Sun,
I've got the following JSON provided from a server. With this, I want to
I've got a java server launched from a jar that uses log4j (RollingFile and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.