No NSTextContainer being returned for glyph range
No NSTextContainer being returned for glyph range
- Subject: No NSTextContainer being returned for glyph range
- From: "Mike R. Manzano" <email@hidden>
- Date: Wed, 6 Sep 2006 15:44:51 -0700
Hi all,
Consider this code snippet:
NSLayoutManager* lm = [ [ _textStorage layoutManagers ] objectAtIndex:
0 ] ;
// Find the glyph range for this range
NSRange glyphRange = [ lm
glyphRangeForCharacterRange:_currentCursorPosition
actualCharacterRange:nil ] ;
// Get the container for this glyph range
if( [ lm isValidGlyphIndex:glyphRange.location ] )
{
NSTextContainer* container = [ lm
textContainerForGlyphAtIndex:glyphRange.location effectiveRange:nil
withoutAdditionalLayout:NO ] ;
NSAssert1( container != nil , @"container is nil for char range %@" ,
NSStringForRange( [ lm characterRangeForGlyphRange:glyphRange
actualGlyphRange:nil ] ) ) ;
[…]
The assertion (NSAssert1) is being thrown every now and then during
program execution. The if statement validates that the glyphRange in
question is valid. The call to
textContainerForGlyphAtIndex:effectiveRange:withoutAdditionalLayout:
should finish the layout so that a valid response can be returned.
My question is, if the glyph range is a valid one, and the layout is
ensured to be finished, then can't I assume a valid container to be
returned every time?
Thanks in advance,
Mike Manzano
alephx01 (at) mac (dot) com
_______________________________________________
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