IOS: Call javascript function from native code

Today I've some work with UIWebview and Javascript. I'm using NativeBridge to call ios function from Javascript. It's quite simple, so I've decided to take note for any further use in the future.

NSString *Data = @"Data You Want To Pass To Javascript Function";
[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"jsFunc('%@')",Data]];

Notice that when you're passing a string to a javascript function, you must put that data inside a pair of ' sign.

Comments

Popular posts from this blog

SFML - Lập trình game - Cài Đặt

No visible @interface for class declares the selector

Test Answer: oDesk Readiness Test for Independent Contractors and Staffing Managers