开发者

read single line from text file in objective-C

开发者 https://www.devze.com 2022-12-14 02:53 出处:网络
I want to read a text file in Objective-C till a specified delimiter For eg:if this is my .txt input file ,

I want to read a text file in Objective-C till a specified delimiter For eg:if this is my .txt input file ,

@abc = name1$ 
@xyz = name2$

i want to read abc and assign it in the string variable key,and read name1 till $ and assign it to variable value

for eg:expected output

key = abc
value= name1
key = xyz
value= name2

Kindly suggest开发者_如何学Go me some solution, which functions are available in objective-C, what is its syntax.


Get the -filedescriptor from the NSFileHandle, then use fdopen to retrieve a FILE *, finally use fscanf to read formatted input.

Or, read the whole file into an NSString and -enumerateLinesUsingBlock: to act on each line individually.

0

精彩评论

暂无评论...
验证码 换一张
取 消