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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:13:08+00:00 2026-06-09T14:13:08+00:00

I got hello world text to print after I hardcoded some html right into

  • 0

I got “hello world” text to print after I hardcoded some html right into my UIWebView functions, but now I am trying to move that HTML to a file elsewhere on the file system, and it isnt rendering.

Here is what I have:

- (void)viewDidAppear:(BOOL)animated
{   
    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"learn" ofType:@"html" inDirectory:@"src/html_files"];

    NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
    [theWebView loadHTMLString:htmlString baseURL:nil];
}

and my HTML file is in a directory that I made called src/html_files and the file is named learn.html

What am I doing incorrectly that the HTML is not rendering on the screen?

Thank you!

  • 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-09T14:13:09+00:00Added an answer on June 9, 2026 at 2:13 pm

    Ok, so Groups are just a construct in Xcode for keeping your app’s resources organized. Although Xcode uses the little folder icon, it doesn’t necessarily mean those are actually separate folders on the (Mac or iOS) filesystem.

    But, it sounds like you have added that file as a bundle resource. That’s what the code you posted looks like, too, but I had to ask, to be sure.

    Most likely, the only thing wrong is that this:

    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"learn" 
                                                         ofType:@"html" 
                                                    inDirectory:@"src/html_files"];
    

    should be this instead:

    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"learn" 
                                                         ofType:@"html"];
    

    From the Apple documentation for NSBundle,

    + (NSString *)pathForResource:(NSString *)name 
                           ofType:(NSString *)extension 
                      inDirectory:(NSString *)bundlePath
    

    bundlePath

    The path of a top-level bundle directory. This must be a valid path. For example, to
    specify the bundle directory for a Mac app, you might specify the path /Applications/MyApp.app.

    The bundlePath parameter is not meant to specify relative paths to your bundle resources. The version of pathForResource:ofType: that does not have a bundlePath parameter is almost always what you’ll use. It will find the learn.html file wherever it lives, once your app is installed, and return the full path to that. You don’t really have to worry about how it’s nested. It’s just a bundle resource.

    Give that a try. As I suggested in my comment, though, I always recommend taking advantage of the error parameter for debugging:

    NSError* error;
    NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error: &error];
    if (error != nil) {
        NSLog(@"Error with stringWithContentsOfFile: %@", [error localizedDescription]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got the following html: <div class=inputContainer> <div class=inputPlaceholder>Hello world</div> <input type=text class=input />
I've got some XML (valid XHTML) that looks like this: <html> <head> <script type=text/javascript>
I got this code ` // // prints out Hello World! // hello_world(); //First
Hello folks, I've got the issue to add a browser event to some input
I need to turn HTML into equivalent Markdown-structured text. OBS.: Quick and clear way
I am new to JSP EL. I am reading some EL text and got
Right now I've got a mod_wsgi script that's structured like this.. def application(environ, start_response):
I've got a button, two textboxes and some text. How to put all this
Hello got the error in following code.. The method RefeshDataGridView() is static.I run it
Hello I've got this query to get users by email, which is an unique

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.