Re: Displaying a number with Quartz

2009-05-26 Thread Graham Cox
On 27/05/2009, at 12:34 PM, Graham Cox wrote: On 27/05/2009, at 12:24 PM, Pierre Berloquin wrote: That would mean dropping all the niceties of Quartz that lets me draw outlined text, for one. That's not the case. The attributes you pass in - drawAtPoint:withAttributes: can include outlin

Re: Displaying a number with Quartz

2009-05-26 Thread Graham Cox
On 27/05/2009, at 12:24 PM, Pierre Berloquin wrote: That would mean dropping all the niceties of Quartz that lets me draw outlined text, for one. That's not the case. The attributes you pass in - drawAtPoint:withAttributes: can include outlines (NSStrokeWidthAttributeName) in different co

Re: Displaying a number with Quartz

2009-05-26 Thread Pierre Berloquin
dev@lists.apple.com > > Sent: Tuesday, May 26, 2009 9:13:26 AM > > Subject: Re: Displaying a number with Quartz > > > > Finally, thanks to Alexander, my pure Objective C solution is > > NSString *S = [[NSString alloc] initWithFormat:@"%i", i]; > > co

Re: Displaying a number with Quartz

2009-05-26 Thread Ken Thomases
On May 26, 2009, at 11:58 AM, Pierre Berloquin wrote: Yes you are right, we work with limited memory and I should be release minded and watch my variables. But didn't I read somewhere an advice against oneliners to skip the releases? It's a trade-off of best efficiency vs. developer conveni

Re: Displaying a number with Quartz

2009-05-26 Thread Gunnar Proppe
.html Gunnar - Original Message > From: Pierre Berloquin > To: Sean McBride > Cc: cocoa-dev@lists.apple.com > Sent: Tuesday, May 26, 2009 9:13:26 AM > Subject: Re: Displaying a number with Quartz > > Finally, thanks to Alexander, my pure Objective C solution is

Re: Displaying a number with Quartz

2009-05-26 Thread Pierre Berloquin
Yes you are right, we work with limited memory and I should be release minded and watch my variables. But didn't I read somewhere an advice against oneliners to skip the releases? Pierre 2009/5/26 Ken Thomases > On May 26, 2009, at 11:13 AM, Pierre Berloquin wrote: > > Finally, thanks to Alexan

Re: Displaying a number with Quartz

2009-05-26 Thread Ken Thomases
On May 26, 2009, at 11:13 AM, Pierre Berloquin wrote: Finally, thanks to Alexander, my pure Objective C solution is NSString *S = [[NSString alloc] initWithFormat:@"%i", i]; const char *text = [S UTF8String]; Don't forget, after you're through with S: [S release]; Or, you could use

Re: Displaying a number with Quartz

2009-05-26 Thread Pierre Berloquin
Finally, thanks to Alexander, my pure Objective C solution is NSString *S = [[NSString alloc] initWithFormat:@"%i", i]; const char *text = [S UTF8String]; and no warning this time except that I should learn more about C Thanks Pierre 2009/5/26 Sean McBride > On 5/26/09 5:12 PM, Alexander Spohr

Re: Displaying a number with Quartz

2009-05-26 Thread Alexander Spohr
Am 26.05.2009 um 17:00 schrieb Sean McBride: Never ever use sprintf for anything. If you use "%d" and know it will be an int? You know how many chars you’ll have at max, no buffer-overflow possible. (You might argue here, that at some time we will habe 128-bit ints, but hey you should re

Re: Displaying a number with Quartz

2009-05-26 Thread Sean McBride
On 5/26/09 5:12 PM, Alexander Spohr said: >> Never ever use sprintf for anything. > >If you use "%d" and know it will be an int? You know how many chars >you'll have at max, no buffer-overflow possible. (You might argue >here, that at some time we will habe 128-bit ints, but hey you should >recode

Re: Displaying a number with Quartz

2009-05-26 Thread Sean McBride
Never ever use sprintf for anything. See here for why: On 5/26/09 3:26 PM, Alexander Spohr said: >sprintf > > > >Am 25.05.2009 um 09:16 schrieb P

Re: Displaying a number with Quartz

2009-05-26 Thread Michael Vannorsdel
NSString's stringWithFormat:, or using sprintf/asprintf with the %d format: char * str; if(asprintf(&str, "%d", intval) < 0) //error CGContextShowTextAtPoint... free(str); or if you know the possible max size of the text: char strbuffer[MAX]; if(snprintf(strbuffer, MAX, "%d", intv

Re: Displaying a number with Quartz

2009-05-26 Thread Alexander Spohr
sprintf Am 25.05.2009 um 09:16 schrieb Pierre Berloquin: Hi I need to display an int with CGContextShowTextAtPoint that only accepts char arrays. How do I go about it ? I can't find how to convert an int into a char* in objective-C !! Thanks Pierre __

Displaying a number with Quartz

2009-05-26 Thread Pierre Berloquin
Hi I need to display an int with CGContextShowTextAtPoint that only accepts char arrays. How do I go about it ? I can't find how to convert an int into a char* in objective-C !! Thanks Pierre ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Plea