PDA

View Full Version : Small help with NSTextView




trey5498
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



robbieduncan
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.

trey5498
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

Sbrocket
Jun 25, 2008, 08:50 AM
http://www.amazon.com/Cocoa-Programming-Mac-OS-3rd/dp/0321503619/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1214401791&sr=8-1

^ Get that for Cocoa.