NSString
can save text up to 4.2 billion characters. \n
denotes a line break, so no need to save into multiple parameters.
NSString *text = textView.text;
OSX
NString *text = [[textView textStorage] string];
If you're looking for each individual line for whatever reason, you could use componentsSeparatedByString
NSArray *linesArray = [textView.text componentsSeparatedByString:@"\n"];
Each line will be available at linesArray[0]
, linesArray[1]
etc...
[linesArray count]
will give you the total number of lines... with linesArray[[linesArray count]-1]
being the last line in the string.
The textView.text
property is an NSString
also... so when you say saved.. do you mean intra app session? If so you can use NSUserDefaults
Save object
[[NSUserDefaults standardUserDefaults]setObject:textView.text forKey:@"TheKeyForMyText"];
Get object
NSString *text = [[NSUserDefaults standardUserDefaults]objectForKey:@"TheKeyForMyText"];