Well...the occurrence of this particular scenario is very rare. It might be
expensive, but, has not had any effects on program performance so far. I am
not in control of the ranges supplied and yes, I could always check if the
range is valid before extracting the substring. However, if the programmer
is expected to do this, then the existence of NSRangeException (and having
substringWithRange: method throw it), seems to be moot (imho) :-)
I might very well end up doing these checks outside the drawRect: routine
and code up drawRect to have different flows based on the results of those
checks. But, the question still does remain, even if purely for academic
reasons - can we clear a UIView (in a custom UITableViewCell) in the
drawRect routine after beginning to draw in it. I have tried playing around
with two options so far
1. CGContextClearRect() - This however clears to a black box and I am not
able to get it to clear transparently. Setting isOpaque:NO on the view in
the nib doesn't seem to have an effect.
2. Fill with white and then draw. This displays ok when then view is not
selected. When it is selected, however, it results in blue color surrouding
the view (with the view remaining white). Filling with blueColor in the
selected state, doesn't seem to work well either. The blue color is a solid
blue, while the selection blue surrounding it seems to be some sort of
gradient


Thanks
George


On Sun, Jul 25, 2010 at 1:07 AM, Graham Cox <graham....@bigpond.com> wrote:

>
> On 25/07/2010, at 6:47 AM, Steve Christensen wrote:
>
> >> I am extracting strings from an NSString and I get NSRange exceptions. I
> could always first check to see if the range is valid, but, figured I would
> save myself the effort and use the exception handling mechanism.
>
>
> NO, this is misguided.
>
> Exceptions are meant to indicate a PROGRAMMER error, not a routine runtime
> situation (clue, they are called exceptions, and so indicate truly
> exceptional circumstances, not just an edge case you couldn't be bothered to
> check for). They are expensive, and should not be used for flow control,
> especially as there is a very simple way to avoid them in this case. If you
> can avoid using exceptions, always do so.
>
> --Graham
>
>
>
_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to