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:
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?
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?