• 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: Fritz Anderson <email@hidden>
  • Date: Sat, 15 Mar 2003 14:37:35 -0600

On Saturday, March 15, 2003, at 12:34 PM, Hussain Bandukwala wrote:

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?


I'm not sure what question 1 means. If it refers to the malloc'ed bytes occupied by the objects themselves, I'd guess that the size would be four bytes for the length of the array, four for the capacity of the array (it it's mutable), plus four times the capacity of the array for the object pointers. But:

-- That makes some assumptions about the implementation of the concrete array classes that I'm not sure are warranted.
-- It gives you information I'm not sure is useful, because it doesn't tell you anything about the contents of the array.

Assuming the array's contents are legal for inclusion in a property list, you can use +[NSPropertyListSerialization dataFromPropertyList:format:errorDescription:] to convert the array to an NSData object, filled with character data, that can you can query for size, save to a file, display, and convert back to an array.

-- F


--
Fritz Anderson - Consulting Programmer - Chicago, IL
Mail: <email@hidden>
Risumi: <http://resume.manoverboard.org>
_______________________________________________
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: Memory management of objects created from Applescript?
  • Next by Date: Re: Problems detecting an active internet connecting using SystemConfiguration
  • Previous by thread: Re: NSMutableArray/NSArray and lossyCString
  • Next by thread: Re: NSMutableArray/NSArray and lossyCString
  • Index(es):
    • Date
    • Thread