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

No visible @interface for class declares the selector

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

IOS UniqueIdentifier in ios 7 (xCode 5)