• 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
Object for variable array of fixed structures
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Object for variable array of fixed structures


  • Subject: Object for variable array of fixed structures
  • From: Steve Sheets <email@hidden>
  • Date: Mon, 12 Jun 2006 16:12:46 -0400

Just another design question...

Are there any examples of good technique to implement variable size arrays of fixed structures?

For example, I want to create an array of NSRect inside my code. Obviously, I could make the data structure be a fixed length array, and not worry about objects. While this array may be small, but occasionally it might be as large as a thousand items in the array. I do not want to always allocated fixed size array all the time.

My solution to handle this involves creating a new category of methods for NSMutableData (named MyMutableArrayRect), which has calls to size the array (based on length of NSRect structure), retrieve items in the array and set items in the array. The new calls look like something like:

- (void) arrayRectSetSize:(int)p_number_item;

- (NSRect) arrayRectGetItem:(int)p_position;

- (void) arrayRectSetItem:(int)p_position
	withRect:(NSRect)p_rect;

Originally the new calls were part of a subclass, but I found using a Category gave me all I needed, while only working with NSMutableData.

Is this the correct approach? I am about to expand this idea to a couple other large fixed size structure, but using the same basic ideas.

Am I missing something and there is a better approach?

Thank you!

Steve Sheets
Midnight Mage Software


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Object for variable array of fixed structures
      • From: Steve Sheets <email@hidden>
    • Re: Object for variable array of fixed structures
      • From: Rush Manbert <email@hidden>
    • Re: Object for variable array of fixed structures
      • From: Jonathon Mah <email@hidden>
  • Prev by Date: distinctUnionOfObjects raises if nil object found
  • Next by Date: Creating Shared Named Objects
  • Previous by thread: distinctUnionOfObjects raises if nil object found
  • Next by thread: Re: Object for variable array of fixed structures
  • Index(es):
    • Date
    • Thread