View Full Version : Small help with NSTextView

Jun 25, 2008, 08:26 AM
ok I got the NSTextView working fine, it took me a sec to figure out that the very top of the Scroll View is the Text View and I have to connect this very small portion with the AppController. Got that fine

I also have the insertText working as well with one small problem. New line is needed.

Here is what I got:

[textView insertText:[arrPRN objectAtIndex: i]];

However when I add the \n right after the first ']' i get syntax and I think that obvious, but I had to try.

How do I get the simple new line with out setting the array to a tmp variable then adding the variable? Basically looking for a shortcut lol

Jun 25, 2008, 08:40 AM
Use the NSString method stringByAppendingString: (http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/stringByAppendingString:)

[textView insertText:[((NSString *) [arrPRN objectAtIndex: i]) stringByAppendingString:@"\n"]];

Note that we need to cast to NSString* as objectAtIndex: returns id.

Jun 25, 2008, 08:47 AM
Ty very very much. Know a good book for after this project to actually sit down and learn more?

I currently have:

Learning Cocoa with Objective-C and Learning Cocoa Applications a step-by-step guide

both by O'Reilly both I think both are a tad bit outdated as they are for up to 10.2 lol

Jun 25, 2008, 08:50 AM

^ Get that for Cocoa.