Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-23-2012, 09:31 AM   #1 (permalink)
learner2011
 
Join Date: Mar 2011
Posts: 115
ashwinr87 is on a distinguished road
Default Passing hexadecimal color values from Xcode to Javascript

Hi,

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,
Code:
NSArray *colorArray = [NSArray arrayWithObjects:@"FFFFFF",@"000000", nil];
    
    colorString = [[colorArray valueForKey:@"description"] componentsJoinedByString:@","];
In my webViewDidFinishLoad function,
Code:
[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 -
Code:
line1.Set('chart.colors', ['FF0000', '000000']);
where instead of giving the hexadecimal values there, I would like to get it from objC.

It would be great if someone could help me out with this.
ashwinr87 is offline   Reply With Quote
Old 01-23-2012, 11:56 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 864
nobre84 is on a distinguished road
Default

Is the quoting required ? You are not surrouding the color code with them.
nobre84 is offline   Reply With Quote
Old 01-23-2012, 12:08 PM   #3 (permalink)
learner2011
 
Join Date: Mar 2011
Posts: 115
ashwinr87 is on a distinguished road
Default

here is what I did to get it working..
Code:
NSArray *array1 = [NSArray arrayWithObjects:@"000000",@"8B0000", nil];
colorString = [NSString stringWithFormat:@"'%@'", [array1 componentsJoinedByString:@"','"]];
and in my javascript -
Code:
line1.Set('chart.colors', [val1[0], val1[1]]);
by this I got color to my graph...
ashwinr87 is offline   Reply With Quote
Reply

Bookmarks

Tags
hexadecimal, ios5, javascript, objective c

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 381
10 members and 371 guests
7twenty7, Atatator, FrankWeller, glenn_sayers, iphonedevshani, MAMN84, mraalex, QuantumDoja, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:48 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0