Thomas Clayson
Thomas Clayson

Reputation: 29925

How to store and retrieve multiple NSStrings in NSData

Is there any way I can store and retrieve multiple text strings in an NSData object?

I am looking into external accessories and just wondering how multiple arbitrary parameters are transmitted to and from the devices.

I assume that they will need to be decoded into NSString objects from an NSData object. So is there any way to distinguish between separate NSString objects from one stream of data?

Or, will multiple string parameters be stored in separate NSData objects? With a buffer for each?

Thanks

Upvotes: 0

Views: 306

Answers (1)

Andy
Andy

Reputation: 14302

Use the NSKeyedArchiver to to archive an array of NSStrings.

+ (NSData *)archivedDataWithRootObject:(id)rootObject

NSKeyedArchiver Reference

Upvotes: 1

Related Questions