Re: What am I looking for in the documentation?

2013-05-10 Thread Fritz Anderson
It should go without saying that the text char array you suggest must already 
exist, and be at least one char longer than the longest string you expect (I'd 
make it twice as long).

And use snprintf(3) instead. Bad People (or you) will try to overrun the buffer 
if you don't prevent it. (Not likely with a %f format spec, but even if you 
trust the dealer, you always cut the cards.)

— F

On 4 May 2013, at 6:23 PM, Mohit Sharma mohit.sharma0...@gmail.com wrote:

 You might want to look at sprintf http://linux.die.net/man/3/sprintf.
 sprintf(text, %f, fv) should work just fine.
 
 
 On Sat, May 4, 2013 at 4:20 PM, YT y...@redwoodcontent.com wrote:
 
 I have need to turn a local float value into a char array.
 
 That is, The Quartz 2D graphics function requires the passing of a (const
 char *) to a text string or I was thinking of a character array.

-- 
Fritz Anderson
Xcode 4 Unleashed: 4.5 supplement for free!
http://www.informit.com/store/xcode-4-unleashed-9780672333279


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: What am I looking for in the documentation?

2013-05-09 Thread Mohit Sharma
You might want to look at sprintf http://linux.die.net/man/3/sprintf.
sprintf(text, %f, fv) should work just fine.


On Sat, May 4, 2013 at 4:20 PM, YT y...@redwoodcontent.com wrote:

 I have need to turn a local float value into a char array.

 That is, The Quartz 2D graphics function requires the passing of a (const
 char *) to a text string or I was thinking of a character array.

 My mind is mush at the moment - can't seem to recall the way to program a
 conversion of

 float fv = 40.0;

 into

 const char *text = 40.0;

 or

 const char text[ ] = 40.0;


 Please advise...

 Thanks YT



 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:

 https://lists.apple.com/mailman/options/cocoa-dev/mohit.sharma0690%40gmail.com

 This email sent to mohit.sharma0...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: What am I looking for in the documentation?

2013-05-06 Thread Sean McBride
On Sat, 4 May 2013 16:20:14 -0700, YT said:

I have need to turn a local float value into a char array. 

That is, The Quartz 2D graphics function requires the passing of a
(const char *) to a text string or I was thinking of a character array.

My mind is mush at the moment - can't seem to recall the way to program
a conversion of 

float fv = 40.0; 

into

const char *text = 40.0;

or 

const char text[ ] = 40.0;

Also consider localisation... do you absolutely want the '.' character, or 
whatever decimal character is specified by the user's locale (or the user 
himself)?  Consider NSNumberFormatter if you want localisation.

Cheers,

-- 

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: What am I looking for in the documentation?

2013-05-06 Thread Rick Mann

On May 6, 2013, at 09:03 , Sean McBride s...@rogue-research.com wrote:

 Also consider localisation... do you absolutely want the '.' character, or 
 whatever decimal character is specified by the user's locale (or the user 
 himself)?  Consider NSNumberFormatter if you want localisation.

Yes! I don't know what I was thinking with my original suggestion. Sean is 
right. Use an NSNumberFormatter.

-- 
Rick




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: What am I looking for in the documentation?

2013-05-06 Thread David Duncan
On May 4, 2013, at 4:20 PM, YT y...@redwoodcontent.com wrote:

 I have need to turn a local float value into a char array. 
 
 That is, The Quartz 2D graphics function requires the passing of a (const 
 char *) to a text string or I was thinking of a character array.


Knowing which API you mean, I would recommend against using it (basically 
Quartz is bad at drawing strings, and you should use a higher level library to 
do that).

NSString has simple methods available on both OS X and iOS for drawing strings 
into the current graphics context, I would highly recommend them instead.
--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: What am I looking for in the documentation?

2013-05-05 Thread YT
Thanks! 

sprintf worked great - Didn't realize that those wonderful Standard C functions 
were available.  

Again, Thanks

YT 


On May 4, 2013, at 4:23 PM, Mohit Sharma mohit.sharma0...@gmail.com wrote:

 You might want to look at sprintf.  sprintf(text, %f, fv) should work just 
 fine.
 
 
 On Sat, May 4, 2013 at 4:20 PM, YT y...@redwoodcontent.com wrote:
 I have need to turn a local float value into a char array.
 
 That is, The Quartz 2D graphics function requires the passing of a (const 
 char *) to a text string or I was thinking of a character array.
 
 My mind is mush at the moment - can't seem to recall the way to program a 
 conversion of
 
 float fv = 40.0;
 
 into
 
 const char *text = 40.0;
 
 or
 
 const char text[ ] = 40.0;
 
 
 Please advise...
 
 Thanks YT
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/mohit.sharma0690%40gmail.com
 
 This email sent to mohit.sharma0...@gmail.com
 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


What am I looking for in the documentation?

2013-05-04 Thread YT
I have need to turn a local float value into a char array. 

That is, The Quartz 2D graphics function requires the passing of a (const char 
*) to a text string or I was thinking of a character array.

My mind is mush at the moment - can't seem to recall the way to program a 
conversion of 

float fv = 40.0; 

into

const char *text = 40.0;

or 

const char text[ ] = 40.0;


Please advise...

Thanks YT



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: What am I looking for in the documentation?

2013-05-04 Thread Rick Mann
You need to do a string conversion, just like you would in any situation where 
you need a textual version of a number.

One possible way:

NSString* s = [NSString stringWithFormat: @%.1f, fv];
const char* sp = s.UTF8String;

another:

char* s[16];
snprintf(s, 16, %.1f, fv);



On May 4, 2013, at 16:20 , YT y...@redwoodcontent.com wrote:

 I have need to turn a local float value into a char array. 
 
 That is, The Quartz 2D graphics function requires the passing of a (const 
 char *) to a text string or I was thinking of a character array.
 
 My mind is mush at the moment - can't seem to recall the way to program a 
 conversion of 
 
 float fv = 40.0; 
 
 into
 
 const char *text = 40.0;
 
 or 
 
 const char text[ ] = 40.0;
 
 
 Please advise...
 
 Thanks YT
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/rmann%40latencyzero.com
 
 This email sent to rm...@latencyzero.com


-- 
Rick




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com