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 6742777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:53:01+00:00 2026-05-26T11:53:01+00:00

I am gratefully thanks for the article Convert NSData bytes to NSString? , especially

  • 0

I am gratefully thanks for the article Convert NSData bytes to NSString?, especially for @christo16. I was previously dependent on ASIHttpRequest just to get value from PHP server. Now using by just this line of code :

NSString *pageContents = [NSData dataWithContentsOfURL: [NSURL URLWithString:@"http://www.apple.com"]]

I can get the functionality that I wanted.

But why is sometimes that line cause pageContents to be NULL. I already change that line into this :

NSString *fullUrl = [NSString stringWithFormat:@"http://www.apple.com"];
NSURL *url = [[NSURL alloc] initWithString:fullUrl];
NSData *pageContents;
NSString *response = NULL;

while(response==NULL)
{
    pageContents = [NSData dataWithContentsOfURL: [NSURL URLWithString:fullUrl]];
    response = [NSString stringWithUTF8String:[pageContents bytes]];
    NSLog(@"content = %@", response);
}

Is there any better way of doing this? Up until now, I have no problem. I just wonder whether there is a more elegant way of achieving the same result

Thanks

  • 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-05-26T11:53:01+00:00Added an answer on May 26, 2026 at 11:53 am

    It will return nil if there is an error retrieving the data.

    You can use the dataWithContentsOfURL:options:error: message to find out why it’s returning nil. The error will be returned in the NSError* pointer that you pass.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

any help you can give is very gratefully accepted. I've been looking at this
When I Ctrl C my program on linux I often get output that looks
I have asked a similar question before, but didn't get very good results. I've
I'm gratefully using the ZipArchive library but it seems there is a memory leak.
I am new to this repository lark, so some help is gratefully received. I
I am having a problem with my c# code I can't seem to get
I friends, I will be very gratefull for any answer, a thanks in advance,
Thanks to this question I managed to work out how to constrain my generic
I have two mysql tables, one listing article names, the other listing the authors
I'm new to Drupal but thanks to our old friend O'Reilly I'm blazing through

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.