• 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
Class Cluster Confusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Class Cluster Confusion


  • Subject: Class Cluster Confusion
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Thu, 19 Jun 2003 13:56:42 +0200

NSFileManager *defaultManager = [ NSFileManager defaultManager ];
id dirContent = [ defaultManager directoryContentsAtPath: aPath ];
NSLog(@"dirContent class: \"%@\"", [ dirContent class ] );

// class is NSCFArray, which is also what the documentation tells me.

// this is a method of NSMutableArray, not of NSArray:
[ dirContent removeObjectAtIndex: 0 ] ;

Now I would expect a run-time error: "-[NSCFArray removeObjectAtIndex:]: selector not recognized", but it just works.
Why?

// Then I did:
NSMutableArray *mutants = [ [ NSMutableArray alloc ] initWithCapacity: count ] ;
NSLog(@"mutants class: \"%@\"", [ mutants class ] );
// class is again NSCFArray

Does this mean that there is no such thing as a NSMutableArray? That this is always the same as NSArray? That the distinction is only for static type checking?

Or what am I misunderstanding here?

Gerriet.
_______________________________________________
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.

  • Follow-Ups:
    • RE: Class Cluster Confusion
      • From: "Jonathan E. Jackel" <email@hidden>
    • Re: Class Cluster Confusion
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Not a drawer but a ... ?
  • Next by Date: Re: disk image
  • Previous by thread: Re: Not a drawer but a ... ?
  • Next by thread: Re: Class Cluster Confusion
  • Index(es):
    • Date
    • Thread