ios從文本文件中讀取內容到字符串里
來源:易賢網 閱讀:1122 次 日期:2015-02-03 14:27:34
溫馨提示:易賢網小編為您整理了“ios從文本文件中讀取內容到字符串里”,方便廣大網友查閱!

nserror *error;

nsstring *textfilecontents = [nsstring

stringwithcontentsoffile:[[nsbundle mainbundle]

pathforresource:@”mytextfile”

oftype:@”txt”]

encoding:nsutf8stringencoding

error: & error];

// if there are no results, something went wrong

if (textfilecontents == nil) {

// an error occurred

nslog(@”error reading text file. %@”, [error localizedfailurereason]);

}

nsarray *lines = [textfilecontents componentsseparatedbystring:@” ”];

nslog(@”number of lines in the file:%d”, [lines count] );

更多信息請查看IT技術專欄

更多信息請查看技術文章
關于我們 | 聯(lián)系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網