Split string by delimiter

淺唱寂寞╮ 提交于 2020-01-02 01:17:04

问题


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...


回答1:


The most html strings will have (mostly invisible) newline delimiters for separating the line

NSArray *lines = [myHtmlString componentsSeparatedByString: @"\n"];
NSString *lineOne = lines[0];
...


来源:https://stackoverflow.com/questions/12291505/split-string-by-delimiter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!