ios - Pulling the raw html string from an htm file stored locally in Xcode -
i have locally stored .htm file , want pull raw html string , display textview. know how display strings in textviews , else, need know how inner strong locally stored .htm file. right can pull path.
first, you'll have add file project , include in application bundle:
- add file project
- select target
- go build phases tab
- expand copy bundle resources section
- add file list
this makes sure file available when application runs on device.
to read content of file when application runs, file path:
nsstring *path = [[nsbundle mainbundle] pathforresource:@"your_file" oftype:@"htm"];
and load file
nserror *error; nsstring *content = [nsstring stringwithcontentsoffile:path encoding:nsutf8stringencoding error:&error];
things watch out for:
- check error value after reading
- if file large, might want read asynchronously
Comments
Post a Comment