Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Monaj

macrumors regular
Original poster
May 24, 2009
193
0
I am trying to use NSTextList to display a numeric list in a multi-line NSTextField but it is not working as intended.

The sample code used is:

Code:
 - (IBAction)displayResult:(id)sender
    {
    	NSTextList *list = [[NSTextList alloc] initWithMarkerFormat:self.markerFormat options:1]; // {Decimal} passed as marker format
    	NSMutableParagraphStyle *paragraph = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
    	[paragraph setTextLists:[NSArray arrayWithObject:list]];
    	[list release];
    	NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:paragraph, NSParagraphStyleAttributeName, nil];
    	NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:self.inputString attributes:attributes] ; // input string is- George \n Thomas \n Ashok
    	[self setOutputString:attrString]; 
    	[attrString release];
    	[paragraph release];
    }

The input is -

George

Thomas

Ashok

The output should be -

1 George

2 Thomas

3 Ashok

but output it is showing is -

George

Thomas

Ashok

Can anyone suggest how to achieve the expected output?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.