views:

203

answers:

2

Hi,

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 me some solution, which functions are available in objective-C, what is its syntax.

A: 

This should help. P.S. Possible duplicate?

Andrejs Cainikovs
A: 

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.

Graham Lee