I really can't find this answer...
I have multiline NSString called myString in XCode, and it is a HTML code. I need to navigate the string by lines, for example:
myString = @"<html>"
"<body>"
"<head><title>My Page</title>";
How can I access line per line? like:
LineOne = myString.Lines[0];
LineTwo = myString.Lines[1];
How can I do something like that in XCode???
I need something like the Memo component in Delphi...
The split() method splits a string into an array of substrings. The split() method returns the new array. The split() method does not change the original string. If (" ") is used as separator, the string is split between words.
split() The method split() splits a String into multiple Strings given the delimiter that separates them. The returned object is an array which contains the split Strings. We can also pass a limit to the number of elements in the returned array.
Split is used to break a delimited string into substrings. You can use either a character array or a string array to specify zero or more delimiting characters or strings. If no delimiting characters are specified, the string is split at white-space characters.
The most html strings will have (mostly invisible) newline delimiters for separating the line
NSArray *lines = [myHtmlString componentsSeparatedByString: @"\n"];
NSString *lineOne = lines[0];
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With