• 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: Help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help


  • Subject: Re: Help
  • From: Fritz Anderson <email@hidden>
  • Date: Mon, 27 Feb 2006 10:16:50 -0600

On Feb 27, 2006, at 8:59 AM, Anoop Thomas varghese wrote:

I have made some changes in sketch example. I am a beginner in cocoa. Our
desired out put is to display the width of text at the mid point of a
line.

Yes... and? You leave us to guess what your difficulty is, or what question you mean to ask.


You do not say what behavior you expect of your code, and what it does instead. Your bezierPath handler has two nearly-identical blocks of code in the middle, with no explanation of why you do this. You end the function with a close-comment marker, but you never open the comment. Assuming you mean to comment-out the second block of code, you do not explain why you include it in your question. You never use the auto variable locationText; what is it? You never use the bezierPath handler in your drawRect: handler; consequently, you never draw the line. The lower-left corner of a rectangle is at the minimum Y, not the maximum. You use the variable name "width" when you mean "length;" this is a potential source of confusion. If a Bézier path is needed elsewhere by Sketch, you don't say so, and many of your potential respondents will not take the trouble to pore through the Sketch source in order to find that out. Your bezierPath handler both returns the Bézier path and, as a side effect, attempts to draw the path; side effects are best avoided in value-returning functions. Passing the drawRect: message in your own code is usually a bad idea, and can never be done without lockFocus or lockFocusIfCanDraw. Better is to use setNeedsDisplay and let Cocoa handle the scheduling and setup. Your bounds-rectangle calculation (which you won't need once you remove the direct call to drawRect:) does not take account of the possibility that the width of the string you mean to draw will be greater than the width of the bounding rectangle of the line itself.

	-- F

 --
Fritz Anderson -- http://www.manoverboard.org/
Consulting Programmer -- http://resume.manoverboard.org/
Step into Xcode, Now Available -- http://six.manoverboard.org/


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Help (From: "Anoop Thomas varghese" <email@hidden>)

  • Prev by Date: Re: Help needed
  • Next by Date: Re: Menu Item Hot Key
  • Previous by thread: Help
  • Next by thread: Problem with copiesOnScroll of NSClipView
  • Index(es):
    • Date
    • Thread