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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:31:51+00:00 2026-06-02T05:31:51+00:00

I declared my App (a rich text editor) to be able to open any

  • 0

I declared my App (a rich text editor) to be able to open any RTF file (coming, for example, from an email attachment). The application delegate sends a “loadContent: (NSURL *) url” message to the UiwebView controller when the user select the attachment. In the receiver, I get the url and load the RTF file in the UIWebView using

- (void) loadContent: (NSURL *) passedURL
{
    if (passedURL) { 
        [self.myWebView loadRequest:[NSURLRequest requestWithURL:passedURL]];
    } else {
        NSBundle *bundle = [NSBundle mainBundle];
        NSURL *indexFileURL = [bundle URLForResource:@"index" withExtension:@"html"];
        [self.myWebView loadRequest:[NSURLRequest requestWithURL:indexFileURL]];

    }
}

Doing that, everything goes all right, and “myWebView” displays the content of the RTF file. The problem is that this view should be content editable, and the code should contain some javascript that I have in my “index.html” bundled file. I load when starting application. So I added some code to extract the HTML code created from the RTF file to be able later to recreate a complete code, inserting the extracted code in a tag like that:

<div id="content" contenteditable="true"> imported html from rtf should be there</div>

I modified the loadContent method to get that.

- (void) loadContent: (NSURL *) passedURL
{
    if (passedURL) { 
        [self.myWebView loadRequest:[NSURLRequest requestWithURL:passedURL]];
        NSString *dum=[self.myWebView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML;"];
        NSLog(@"%@",dum);
    } else {
        NSBundle *bundle = [NSBundle mainBundle];
        NSURL *indexFileURL = [bundle URLForResource:@"index" withExtension:@"html"];
        [self.myWebView loadRequest:[NSURLRequest requestWithURL:indexFileURL]];

    }
}

Looking to the result of the NSLog, I get only the following html

<div id="content" contenteditable="true">Hello folks</div>

Which was the HTML content of myWebView BEFORE I loaded the rtf file…

Do you have any idea of what is going on? Why does dum displays the former code, as the displayed myWebView displays the new one? Is it because the loadRequest is executed in a separated thread and that when executing the next instruction, myWebView still contains the former code?

Thanks

[EDITED] I also tried to NSLog the content of the webView in webViewDidFinishLoad: delegate method, but get the same result: the content of this webView before I opened the RTF attachment file. Is It possible to make a load request in a synchronous way?

  • 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-02T05:31:52+00:00Added an answer on June 2, 2026 at 5:31 am

    This is because loadRequest is asynchronous. You need to wait for the load to finish before trying that NSLog. Take a look at the UIWebViewDelegate docs. Try that NSLog inside/after webViewDidFinishLoad: and you should get better results.

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

Sidebar

Related Questions

I have rich-text file with a few images and text. In my Cocoa app
In this example from the App Engine docs , why does the example declare
I have the following connection string declared in my app.config file: <connectionStrings> <add name=SqlConnectionString
I have declared a variable NSString sessionId; in app delegate file for global usage.
I have two domains declared in my app. class Posts { String title String
I declared a NSArray object in .h file as @property (nonatomic, assign) NSArray *scnArray;
I've experienced something today while I'm building my app. I've declared a protocol in
Given an Android app that does NOT require any of the features that need
Say, an app declared itself as <uses-permission android:name=android.permission.INTERNET /> Is there a way for
I am building an Android app that uses wifi. I have properly declared these

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.