Q: How do I get at the list of runs in a Text object, without subclassing the Text class? Once I have them, how do I determine how many of them there are?

A:

#import <appkit/Text.h>

@interface Text(Private)
- (int)nRuns;
@end

@implementation Text(Private)
-(int)nRuns
{
return theRuns->chunk.used/sizeof(NXRun);
}
@end

main ()
{
id text = [[Text alloc]
initFrame:NULL text:"Hello there" \
alignment:NX_LEFTALIGNED];
printf("there are %d runs.\n", [text nRuns]);
}



QA430

Valid for 2.0, 3.0