我试图用来NSTextList在多行显示数字列表,NSTextField但它没有按预期工作.
使用的示例代码是:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
输入是 -
George
Thomas
Ashok
Run Code Online (Sandbox Code Playgroud)
输出应该是 -
1 George
2 Thomas
3 Ashok
Run Code Online (Sandbox Code Playgroud)
但它显示的输出是 -
George …Run Code Online (Sandbox Code Playgroud)