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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:59:16+00:00 2026-05-14T14:59:16+00:00

I’m working on an app that would display a remote html and use local

  • 0

I’m working on an app that would display a remote html and use local images, so what I’m trying to do is download the HTML of the website and display it as a “local” page, that would have access to images in my bundle.

For some reason I can’t get initWithContentsOfURL to work. I checked all manuals and examples I could find and it seems that I’m doing it correctly, but the thing just won’t work, returns null all the time. The same page loaded with NSURLRequest requestWithURL works fine.

Here is the code:

- (void)awakeFromNib 
{
    appURL = @"http://dragontest.fantasy-fan.org";
    notConnectedHTML = @"Could not connect.";

    NSString *seedString = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/seed.php", appURL]]];

    NSString *HTMLdata = @"";

    if (seedString = @"(null)") {
        NSLog(@"Can't connect on awakeFromNib.");
        HTMLdata = notConnectedHTML;
    }else {
        HTMLdata = [NSString stringWithFormat:@"<body style='padding:0px;margin:0px;'>%@%@</body>", seedString, @"<br><img src='images/Default.png'>"];
    }   
    [homeView loadHTMLString:HTMLdata baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath]]];
}
  • 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-14T14:59:17+00:00Added an answer on May 14, 2026 at 2:59 pm

    Firstly, why aren’t appURL and notConnectedHTML declared as NSString *? Are they declared this way elsewhere?

    Secondly, you might be better off using NSURL‘s -urlWithString:relativeToURL: to create the actual request URL.

    Thirdly (and this is your actual problem here I suspect), to compare two C primitives, you use ==. = is the assignment operator (it makes the thing on the left equal to the thing on the right). To compare two Objective-C objects, use a comparison method, like -isEqual: or -isEqualToString: (which is specifically for NSStrings).

    So instead of:

    if (seedString = @"(null)")
    

    You should use

    if ([seedString isEqualToString:@"(null)"])
    

    However I suspect the reason you’re trying to compare to “(null)” is because that’s what NSLog spits out when an object is equal to nil. When an object is nil, the object reference itself is equal to the nil constant, so you should use this to see if an object is nil:

    if (seedString == nil)
    

    Just for good measure, some people like to use this syntax which does exactly the same thing:

    if (!seedString)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.