Pass Variable (cookie) from local html to UILabel - iOS -


i wanted know how go passing variable (cookie) in local html file in ios app, , pass cookie says onto uilabel. here html code is. need pass message uilabel

<script language="javascript">setcookie('test','you sir have succeeded. congratulations.', 300);  </script> 

and here updated code ios app

header file:

import

@interface viewcontroller : uiviewcontroller {

iboutlet uiwebview *webview; iboutlet uilabel *mylabel;   }    @end 

main file

#import "viewcontroller.h"  @interface viewcontroller ()  @end   @implementation viewcontroller  - (void)viewdidload {      [webview loadrequest:[nsurlrequest requestwithurl:[nsurl fileurlwithpath:[[nsbundle mainbundle] pathforresource:@"dtpcontent/cookietest" oftype:@"html"]isdirectory:no]]];      [super viewdidload];      nsstring *mycookie = [self->webview stringbyevaluatingjavascriptfromstring:@"getcookie('test')"]; self->mylabel.text = mycookie;      }      @end 

thank in advance!

assuming have javascript function cookies, that, can execute javascript webview's method stringbyevaluatingjavascriptfromstring , it's returned string , set in uilabel.

it this:

nsstring *mycookie = [self.webview stringbyevaluatingjavascriptfromstring:@"getcookie('test')"]; self.mylabel.text = mycookie; 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -