Re: NSMutableArray/NSArray and lossyCString
Re: NSMutableArray/NSArray and lossyCString
- Subject: Re: NSMutableArray/NSArray and lossyCString
- From: publiclook <email@hidden>
- Date: Sat, 15 Mar 2003 15:09:11 -0500
On Saturday, March 15, 2003, at 01:34 PM, Hussain Bandukwala wrote:
Hi,
Two questions:
1) Is there any way to obtain the size in bytes of an NSMutableArray
or NSArray object?
2) Is there any way to convert an NSMutableArray or NSArray object
into a lossyCString representation where, the lossyCString
representation can be reconverted into an NSMutableArray or NSArray
object?
Thanks,
Hussain
A lot depends on what you want to do.
One example:
NSString *someString = [someArray description];
const char *someChars = [someString lossyCString];
NSString *restoredString = [NSString stringWithCString:someChars];
NSArray *someArray = [restoredString propertyList];
If you use -description and -propertyList, the array can only contain
objects that have a property list representation. This includes
NSString, NSArray, NSDictionary, NSData, and possibly NSValue. Other
types can be used by wrapping them in a supported type such as NSData.
Another way:
You might consider NSKeyedArchiver and related topics:
http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/
ProgrammingTopics/Archiving/index.html
Tutorial at
http://www.stepwise.com/Articles/VermontRecipes/KeyedArchiving.html
XML files can be converted to C strings and back.
Yet another way:
Archive an entire object graph into NSData and call NSData's
-description method which returns a 7 bit safe (essentially uuencoded)
endian neutral string suitable for sending over sockets etc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.