[英]Display an array in a NSTextView in a NSScrollView object
How would I display an array in a NSTextView
in a NSScrollView
Object in Xcode
? 如何在
Xcode
中的NSScrollView
对象的NSTextView
中显示数组?
For example, just having a simple array of strings like this: 例如,仅具有一个简单的字符串数组,如下所示:
NSMutableArray *thisArrary = [NSMutableArrary new];
[thisArrary addObject:@"String 0\n"];
[thisArrary addObject:@"String 1\n"];
[thisArrary addObject:@"String 2\n"];
And then be able to display the whole array in the NSTextView. 然后能够在NSTextView中显示整个数组。
Would it be easier if I used a string and then added to it each time, and then displayed that in the NSTextView
? 如果我先使用一个字符串然后将其添加到它,然后在
NSTextView
显示它,会更容易吗? For example: 例如:
NSString *thisString = @"String 0\n";
thisString = [NSString stringWithFormat @"%@String 1\n", thisString];
thisString = [NSString stringWithFormat @"%@String 2\n", thisString];
NSArray *strings = @[@"String 0", @"String 1", @"String 2"];
NSString *combinedString = [strings componentsJoinedByString:@"\n"];
textView.string = combinedString;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.