I am trying to load a UIWebView with local HTML/CSS that is build to look like a nutrition label. The problem is, the data for the food lies inside of my iPhone app. Do I have to put all of my HTML into one enormous NSString object and concatenate my data into it, or is there a way to load the HTML from a local .html file, but somehow “inject” the data that is stored within Objective-C into it?
Share
If the data to be injected is “safe”, you could construct your “enormous NSString object” as a format string, sprinkled with
%@markers, and usestringWithFormat:to perform the injection in a single move. This is how I construct the pages in the TidBITS News app, using pieces that all come from RSS. It’s really quite painless.