I am trying to pass a Hexadecimal color value from objectiveC to Javascript. I am displaying a graph and I am trying to pass the color to javascript so that I dont need to hardcode it in my html page.
Here is what I do –
In my .m File,
NSArray *colorArray = [NSArray arrayWithObjects:@"FFFFFF",@"000000", nil];
colorString = [[colorArray valueForKey:@"description"] componentsJoinedByString:@","];
In my webViewDidFinishLoad function,
[graphView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"methodName1([%@])", colorString]];
However, the javascript is not able to accept the values.
In my Javascript function, what should I do to accept the values – FFFFFF and 000000 so that I can use them.
I am trying to use the colors like this –
line1.Set('chart.colors', ['FF0000', '000000']);
where instead of giving the hexadecimal values there, I would like to get it from objC.
Update –
Here is the javascript function I use –
function methodName1(val)
{
alert("hi");
}
However, the function does not even get called.. I feel the issue is with the way I pass the values…
It would be great if someone could help me out with this.
You’re calling
But you want