• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Displaying a number with Quartz
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Displaying a number with Quartz


  • Subject: Re: Displaying a number with Quartz
  • From: Gunnar Proppe <email@hidden>
  • Date: Tue, 26 May 2009 10:11:55 -0700 (PDT)

Actually, your pure Objective C version would be to use NSString's drawAtPoint:withAttributes instead of converting to a char* and using CGContextShowTextAtPoint.

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSString_AppKitAdditions/Reference/Reference.html

Gunnar


----- Original Message ----
> From: Pierre Berloquin <email@hidden>
> To: Sean McBride <email@hidden>
> Cc: email@hidden
> 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];
> 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 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 your app then anyway or just have a buffer large enough to
> > >handle that right at the start)
> > >
> > >And yes - you are right, use snprintf instead... int might become 256
> > >bit.
> >
> > You can use sprintf safely if you're very careful, I suppose, but using
> > snprintf is not harder and so much safer.  sprintf is just not worth the
> > risk.
> >
> > --
> > ____________________________________________________________
> > Sean McBride, B. Eng                email@hidden
> > Rogue Research                        www.rogue-research.com
> > Mac Software Developer              Montréal, Québec, Canada
> >
> >
> >
>
>
> --
> Blogs : http://bibliobs.nouvelobs.com/blog/jeux-litteraires
>           http://pierre-berloquin.blogspot.com/
>
> Développement durable des neurones par le jeu de réflexion
> www.crealude.net
>
> Sustainable development of neurones through mind games
> www.crealude.net/us
>
> Que fait-on pour les mal-codants ?
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Displaying a number with Quartz
      • From: Pierre Berloquin <email@hidden>
References: 
 >Displaying a number with Quartz (From: Pierre Berloquin <email@hidden>)
 >Re: Displaying a number with Quartz (From: Alexander Spohr <email@hidden>)
 >Re: Displaying a number with Quartz (From: "Sean McBride" <email@hidden>)
 >Re: Displaying a number with Quartz (From: Alexander Spohr <email@hidden>)
 >Re: Displaying a number with Quartz (From: "Sean McBride" <email@hidden>)
 >Re: Displaying a number with Quartz (From: Pierre Berloquin <email@hidden>)

  • Prev by Date: Re: NULL Outlets in one file work in another
  • Next by Date: Re: How to draw background image in my app window
  • Previous by thread: Re: Displaying a number with Quartz
  • Next by thread: Re: Displaying a number with Quartz
  • Index(es):
    • Date
    • Thread