[Help] loading text file into UITextView

Discussion in 'iOS Development' started by ibo2001, Oct 6, 2009.

  1. ibo2001

    ibo2001 New Member

    Joined:
    Sep 5, 2008
    Messages:
    4
    Likes Received:
    0
    Hi

    first: sorry if my english wasnt so good.

    second, i nead to load a text file with multilines quotes "more that 200 quotes" into a UITextView, my UIView has tow buttons [Next and previous] , i need to display the text file line by line.

    i know that i will load the file using NSString and separate the lines using componentsSeparatedByString: @"\n" .

    i am counfused with the buttons actions, i mean how to make action just to load one line at time..

    I hope that i can get som help with good sample code or just point me to good start.
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    If you're using -componentsSeparatedByString:, then you're working with an array, as that's what that method returns. Just use an int to keep track of the current index. Have the button increment or decrement that variable, then reload the text to the text at the new index.
  3. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    You could use that method you said to get an array, and then switch the contents of the text field to the next item in the array...

Share This Page