• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSMutableArray/NSArray and lossyCString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
References: 
 >NSMutableArray/NSArray and lossyCString (From: "Hussain Bandukwala" <email@hidden>)

  • Prev by Date: Re: Problems detecting an active internet connecting using SystemConfiguration
  • Next by Date: Re: objc_category?
  • Previous by thread: NSMutableArray/NSArray and lossyCString
  • Next by thread: Re: NSMutableArray/NSArray and lossyCString
  • Index(es):
    • Date
    • Thread