• 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: fetching from NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fetching from NSArray


  • Subject: Re: fetching from NSArray
  • From: Ricky Sharp <email@hidden>
  • Date: Tue, 2 Oct 2007 18:58:58 -0500


On Oct 2, 2007, at 6:39 PM, Andy Lee wrote:

On Oct 2, 2007, at 7:17 PM, Charles Steinman wrote:
I'm not at a computer where I can test it, but I
assume it's a standard C array:

Oh, that would make sense. For some reason the first thing I thought of was that the id* was to return a single id by reference, in which case it would have made more sense to simply return it by value. But returning a C array makes sense by analogy to NSString's -getCharacters:range:. The documentation should therefore be similar IMO.

That's definitely a strange API:

NSArray* theArray = [NSArray arrayWithObjects:@"a", @"b", @"c", @"d", @"e", nil];

NSLog (@"theArray = %@", theArray);


id p = calloc (2, sizeof (id));

[theArray getObjects:&p range:NSMakeRange (1, 2)];

NSString* theFirstString = (NSString*) p;
p += sizeof (id);
NSString* theSecondString = (NSString*) p;

NSLog (@"theFirstString = %@", theFirstString);
NSLog (@"theSecondString = %@", theSecondString);

output:

theArray = (a, b, c, d, e)
theFirstString = b
theSecondString = a



I tried other locations for the range too; the order of objects returned is backwards as I would have expected :) Of course, I haven't yet tried this with three or more objects, so do not know if getObjects is always returning objects in the opposite order of storage in the array, or if the order is just random.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: fetching from NSArray
      • From: Sherm Pendley <email@hidden>
References: 
 >Re: fetching from NSArray (From: Charles Steinman <email@hidden>)
 >Re: fetching from NSArray (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: Sorting one column table?
  • Next by Date: Re: NSButton Behaviors
  • Previous by thread: Re: fetching from NSArray
  • Next by thread: Re: fetching from NSArray
  • Index(es):
    • Date
    • Thread