Small help with NSTextView

Discussion in 'Mac Programming' started by trey5498, Jun 25, 2008.

  1. trey5498 macrumors regular

    Jun 16, 2008
    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
  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    Use the NSString method stringByAppendingString:

    [textView insertText:[((NSString *) [arrPRN objectAtIndex: i]) stringByAppendingString:@"\n"]];
    Note that we need to cast to NSString* as objectAtIndex: returns id.
  3. trey5498 thread starter macrumors regular

    Jun 16, 2008
    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

Share This Page