0

How would I display an array in a NSTextView in a NSScrollView Object in Xcode?

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.

Would it be easier if I used a string and then added to it each time, and then displayed that in the NSTextView? For example:

NSString *thisString = @"String 0\n";
thisString = [NSString stringWithFormat @"%@String 1\n", thisString];
thisString = [NSString stringWithFormat @"%@String 2\n", thisString];
βhargavḯ
  • 9,786
  • 1
  • 37
  • 59
  • You should learn how to use scrollview and textview, Check this [Apple Doc](https://developer.apple.com/library/mac/documentation/cocoa/conceptual/TextUILayer/Tasks/TextInScrollView.html) – Toseef Khilji Dec 24 '13 at 06:05

1 Answers1

1
NSArray *strings = @[@"String 0", @"String 1", @"String 2"];
NSString *combinedString = [strings componentsJoinedByString:@"\n"];
textView.string = combinedString;
indragie
  • 18,002
  • 16
  • 95
  • 164