Re: Trouble finding bounding rect of NSAttributedString
Re: Trouble finding bounding rect of NSAttributedString
- Subject: Re: Trouble finding bounding rect of NSAttributedString
- From: Jens Alfke <email@hidden>
- Date: Thu, 19 Nov 2009 15:28:01 -0800
On Nov 19, 2009, at 2:39 PM, Dave DeLong wrote:
> When I print out the size or rect that these return, I invariably get either {0, 0} or something absurd like {{1.17076e-318, 2.29357e-314}, {2.30359e-314, 2.1224e-314}} (that's just running the rect through NSStringFromRect())
Make sure the receiver (the NSAttributedString) isn't nil. The Obj-C runtime gives undefined results for a struct-based method return value if the receiver is nil; so you'll end up with garbage like this. (This is because it doesn't know at runtime how large the struct is, so it can't safely fill it in with zeroes.)
Put in something like NSAssert(str!=nil, @"str is nil"); before the call.
—Jens_______________________________________________
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