Integrating jquery-javascript project in my iOS app
===

I am trying to get the prominent colors in an image. Initially I was trying to get the color set as in [this post][1]. But my client is not satisfied with it as it returns only the average color set and not the exact color. Hence now Im trying to get the dominant color set by the logic found in [this link.][2] But the problem is that the code is in jQuery and JavaScript. 
Seems its easy to implement in the web as the code is very simple as

    myImage = $('#myImage');
    dominantColor = getDominantColor(myImage);
    paletteArray = createPalette(myImage, 10); // 2nd argument sets # of colors in palette


I surfed how to execute JS in iOS and did in reference to [this link][3] and [this link][4] and did as below

    [_webView loadHTMLString:@"<script src=\"color-thief.js\"></script>" baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath]]];
    
        NSString * imgName = [[NSBundle mainBundle] pathForResource:@"4" ofType:@"jpg"];
    //    UIImage * img = [UIImage imageNamed:imgName];
        int colorCount = 9;
    
        NSString *function1 =[[NSString alloc] initWithFormat: @"createPalette(%@, %d)", imgName, colorCount];
    //    NSString *function2 = [[NSString alloc] initWithFormat: @"getAverageRGB(%@)", imgName];
        NSString *result = [_webView stringByEvaluatingJavaScriptFromString:function1];
    
        NSLog(@"%@ result %@", result, [_webView stringByEvaluatingJavaScriptFromString:funcion1]);


But I couldn't get any result. Its null. What am I missing? Can some one point me what went wrong? Any timely help is appreciated. Thanks in advance.


  [1]: http://www.iphonedevsdk.com/forum/iphone-sdk-development/103877-get-prominent-colors-in-an-image.html
  [2]: http://lokeshdhakar.com/projects/color-thief/
  [3]: http://stackoverflow.com/a/8436281/1424174
  [4]: https://stevenpsmith.wordpress.com/2011/01/20/executing-javascript-from-objective-c-in-an-ios-app/