ios - Merge html files into UIWebView -


i have create uiwebview adding data i'm getting api html file have locally. it's first time have , can't find how this.

my html file looks :

 <h1>%%%title%%%</h1>         <p class="date">%%%date%%%</p>         <a %%%hrefimage%%% class="link-diapo">             <div class="image">                 <img src="%%%img%%%" alt="%%%title%%%"/>                 %%%diapo%%%             </div>         </a>         <div id="content" style="font-size:%%%size%%%px;">             <p>%%%chapo%%%</p>             <p>%%%html%%%</p>             <p class="source">%%%author%%%</p>         </div> 

and data :

        "title": "my title",         "date": "2013-07-10",         "hour": "19h45",         "chapo": "blablabla",         "author": "me",         "description": "html text" ... 

is there method ? or have detect %%% in html file ?

thx !

if have initial html in nsstring, use stringbyreplacingoccurrencesofstring:withstring:, like

nserror *error; nsstring *initialhtmlstring = [nsstring stringwithcontentsoffile:(your file path) encoding:nsutf8stringencoding error:&error];  //do data api, i'll assume nsdata w/ json formatting nsdictionary *jsondic = [nsjsonserialization jsonobjectwithdata:jsondata options:kniloptions error:nil]; nsstring *titlestring = [jsondic objectforkey:@"title"];  nsstring *htmlstringwithtitleadded = [initialhtmlstring stringbyreplacingoccurencesofstring:@"%%%title%%%" withstring:titlestring]; 

you need repeat each of key data getting api.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -