Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-09-2012, 06:05 AM   #1 (permalink)
generic twenty-something
 
jakerocheleau's Avatar
 
Join Date: Dec 2011
Location: Massachusetts
Age: 20
Posts: 54
jakerocheleau is on a distinguished road
Default UIWebView Difference between loadRequest and loadHTMLString:baseURL:?

I'm getting into loading web views and I don't have any problems, just a bit curious regarding "best-practices" for development.

From what I can tell there are 2 different ways to load HTML content and they both appear exactly the same in my view. One is through loadRequest which uses an NSURLRequest and the other loads HTML from a base URL.

PHP Code:
NSString *path = [[NSBundle mainBundlepathForResource:@"index" ofType:@"html" inDirectory:@"www"];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:baseURL];

[
webview loadRequest:request]; 
PHP Code:
NSString *path = [[NSBundle mainBundlepathForResource:@"index" ofType:@"html" inDirectory:@"www"];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSError *error;
NSString *htmlstring = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];

[
webview loadHTMLString:htmlstring baseURL:baseURL]; 
Is there any specific benefit to using one method over the other? I tried googling and checking throughout the forums but I can't find any solid info comparing these 2 procedures. Right now I'm using loadRequest because it's neater in my code.

From what I can tell there is absolutely no difference in the final, compiled running application. Would love to hear input from others more knowledgable on the subject
__________________
I write, design apps, code Objective-C, and research my life away.
jakerocheleau is offline   Reply With Quote
Old 02-09-2012, 06:23 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2012
Location: BHOPAL
Posts: 11
iphonedev.pmd is on a distinguished road
Default

loadHTMLString we load the html string
and in loadRequest we load the url
i
iphonedev.pmd is offline   Reply With Quote
Old 02-10-2012, 07:17 AM   #3 (permalink)
generic twenty-something
 
jakerocheleau's Avatar
 
Join Date: Dec 2011
Location: Massachusetts
Age: 20
Posts: 54
jakerocheleau is on a distinguished road
Default

Quote:
Originally Posted by iphonedev.pmd View Post
loadHTMLString we load the html string
and in loadRequest we load the url
i
do you think loadHTMLString is quicker than loadRequest?

I notice a small delay on my app when you first view the files. But this has only happened a few times with loadRequest. I assume pulling all the HTML into a string to display would be more memory-intensive
__________________
I write, design apps, code Objective-C, and research my life away.
jakerocheleau is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 404
12 members and 392 guests
chiataytuday, chits12345, fiftysixty, gmarro, KennyChong, kilobytedump, Leslie80, Matrix23, Meoz, ryantcb, xerohuang, Yosh_K
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,670
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Yosh_K
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:24 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0