• 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: (Newb) Populate NSMutableDictioanry with NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (Newb) Populate NSMutableDictioanry with NSArray


  • Subject: Re: (Newb) Populate NSMutableDictioanry with NSArray
  • From: Keary Suska <email@hidden>
  • Date: Sun, 31 Aug 2008 14:21:32 -0600
  • Thread-topic: (Newb) Populate NSMutableDictioanry with NSArray

8/31/08 2:34 AM, also sprach email@hidden:

> NSMutableDictionary * myCollection;
> myCollection = [[NSArray alloc] initWithObjects:@"a", @"b", @"c", nil];
>
> The types are not the same. So my first question is, is this a bug?
> And if so, why didn't the compiler catch it? I come from C# so unless
> NSMutableDictionary inherits NSArray this logic would not compile.

Yes, it is a "bug". Because the return type of -initWithObjects is "id",
which can represent any object, the compiler can't know that the types are
incompatible.

IIRC, you should get a compiler warning if you call a method that only
NSArray implements, such as -objectAtIndex:, on the myCollection object.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

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

References: 
 >(Newb) Populate NSMutableDictioanry with NSArray (From: Jon Davis <email@hidden>)

  • Prev by Date: App names
  • Next by Date: Re: Sending a GET or POST HTTP request with Cocoa
  • Previous by thread: (Newb) Populate NSMutableDictioanry with NSArray
  • Next by thread: Re: (Newb) Populate NSMutableDictioanry with NSArray
  • Index(es):
    • Date
    • Thread