简体   繁体   中英

NSInputStream wrapper to read strings by specified delimiter

I am porting a java client to the iphone and i have been wondering if there is a wrapper around NSInputStream to read strings from a stream stopping at a specified delimiter? I am thinking of something like Javas Scanner class (http://download.oracle.com/javase/6/docs/api/index.html?overview-summary.html).

I need this functionality because my iphone client is recieving messages from the server where the end of a message is defined by the chars CR and LF

I have been searching google and stackoverflow without any luck. Just asking to make sure i dont start re-inventing the wheel so to speak.

Thanks for any help! :=)

I don't think that's possible. Maybe you could read the stream to a buffer, convert to NSString and search for your delimiters. NSInputStream allows you to read chunks of N bytes but you have to convert it to an NSString on your own and then work on your logic with the delimiters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM