xcode 通过分隔符拆分字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12291505/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Split string by delimiter
提问by Guilherme Correa Teixeira
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:
我在 XCode 中有名为 myString 的多行 NSString,它是一个 HTML 代码。我需要按行导航字符串,例如:
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???
我怎么能在 XCode 中做这样的事情???
I need something like the Memo component in Delphi...
我需要像 Delphi 中的 Memo 组件之类的东西...
回答by brainray
The most html strings will have (mostly invisible) newline delimiters for separating the line
大多数 html 字符串将具有(大部分不可见的)换行符来分隔行
NSArray *lines = [myHtmlString componentsSeparatedByString: @"\n"];
NSString *lineOne = lines[0];
...