home *** CD-ROM | disk | FTP | other *** search
Wrap
{\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;\f2\fmodern Ohlfs;} \paperw10860 \paperh7040 \margl120 \margr120 {\colortbl;\red0\green0\blue0;\red84\green84\blue84;\red83\green83\blue83;} \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f0\b0\i0\ulnone\fs28\fc0\cf0 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?\ \ \fc1\cf1 A:\ \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f1\fs24\fc1\cf1 \ #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]);\ \}\ \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f0\fs28\fc0\cf0 \ \ QA430\ \ Valid for 2.0, 3.0\ \