views:

30

answers:

1

Can someone please help me out with this I'm actually going nuts!

What is the best way to get text from a plain .txt file into a Scroll View, thats all I need just text.

I've tried so many different solutions but can't get any of them working I was hoping someone could give me a fresh overview.

A: 

Is the file a resource in your application or are you loading it from a network resource? If embedded, you can load it into an NSString object and then set the text property of the UITextView with that. Something like:

UITextView *myTextView = [[UITextView alloc] init];
NSString *pathToFile = [[NSBundle mainBundle] pathForResource:@"yourTextFile" ofType:@"txt"];  
NSString *theText = [NSString stringWithContentsOfFile:pathToFile encoding:NSUTF8StringEncoding error:nil];
myTextView.text = theText;
Typeoneerror
Just noticed you were asking about scroll view. guess it doesn't matter since you just need to load the text from the file anyway. hope this works.
Typeoneerror
Yeah the file is in my resources folder, I will try this out thanks for our help
Charles Marsh