简体   繁体   中英

CTLine Ref coming nil + CoreText + iPhone

I am facing a strange problem with CTFrameGetLines( frameRef ) method of Core Text API. I am getting an array of all CTLines that are present in a frame using function

CFArrayRef lines =   CTFrameGetLines( frameRef );

and then I am calculating no. of lines that are present using

    linesCount = CFArrayGetCount (lines);

In my case linesCount is coming to be 28. But when I try get line at index 17 in lines array using

line = (CTLineRef) [(NSArray *)lines objectAtIndex:i];

I am getting line as nil. I am not able to figure out when value of linesCount is coming to be 28 , then how come the value at 17th index in lines array be nil.There's need to be some line present at index 17.

Kindly help me in resolving this issue, this is really very urgent.

Thanx in advance, Regards, tek3

objectAtIndex: should never return nil unless the receiver is nil. That would mean 'lines' is NULL. Maybe the call to CTFrameGetLines is failing. That doesn't explain why CFArrayGetCount would return 28 though. Does it return 28 every time? What does CFArrayGetValueAtIndex return?

Andrew

(CTLineRef)CFArrayGetValueAtIndex(lines,i);

use this instead of NSArray

line = (CTLineRef) [(NSArray *)lines objectAtIndex:i];

and make shore you not releasing lines before.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM