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.
精彩评论