• 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: Bold and Italic For Dictionary Font Attributes (Hillegass Chapter 20, Challenge 2)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bold and Italic For Dictionary Font Attributes (Hillegass Chapter 20, Challenge 2)


  • Subject: Re: Bold and Italic For Dictionary Font Attributes (Hillegass Chapter 20, Challenge 2)
  • From: Russell Finn <email@hidden>
  • Date: Sat, 31 Oct 2009 15:44:01 -0400

On Wed, Oct 28, 2009 at 8:27 PM, Graham Cox <email@hidden> wrote:
>
> On 29/10/2009, at 7:02 AM, Russell Finn wrote:
>
>> I'm pretty sure you got this backwards -- it's ObjectsAndKeys, not
>> KeysAndObjects:
>>
>> attributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
>>      [NSFont fontWithName:@"Helvetica" size:75],  NSFontAttributeName,
>>      NSColor redColor], NSForegroundColorAttributeName,
>>      shadow, NSShadowAttributeName,
>>      nil];
>>
>
> No, the OP is right. Check again:
>
>> initWithObjectsAndKeys:
>> Initializes a newly allocated dictionary with entries constructed from the
>> specified set of values and keys.
>>
>> - (id)initWithObjectsAndKeys:(id)firstObject , ...
>>
>> Parameters
>> firstObject
>> The first value to add to the new dictionary.
>>
>> ...
>> First the key for firstObject, then a null-terminated list of alternating
>> values and keys. If any key is nil, an NSInvalidArgumentException is raised.

Right.  But Jens had had:

> attributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
>        NSFontAttributeName, [NSFont fontWithName:@"Helvetica" size:75],
>        NSForegroundColorAttributeName, NSColor redColor],
>        NSShadowAttributeName, shadow,
>        nil];

-- i.e. key, object, key, object; this is what I tried to correct this
in my post, as shown above.  (I should have explicitly noted I was
posting a modified version of the original code fragment.)

> Usually when coming up with a method name, it should self-document as far as
> possible. These nil-terminated lists don't fully do that, but at least the
> order of words gives you a hint:
>
> initWithObjects(first)andKeys(second)
>
> Therefore the list is ordered object, key, object, key

Right.  But that's not what Jens had posted, which is why I jumped in.
 (Note that his $dict utility function does have object, key, object,
key.)

-- Russell
_______________________________________________

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: 
 >Bold and Italic For Dictionary Font Attributes (Hillegass Chapter 20, Challenge 2) (From: Chunk 1978 <email@hidden>)
 >Re: Bold and Italic For Dictionary Font Attributes (Hillegass Chapter 20, Challenge 2) (From: Jens Alfke <email@hidden>)
 >Re: Bold and Italic For Dictionary Font Attributes (Hillegass Chapter 20, Challenge 2) (From: Russell Finn <email@hidden>)
 >Re: Bold and Italic For Dictionary Font Attributes (Hillegass Chapter 20, Challenge 2) (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Double-clicking a screensaver
  • Next by Date: Re: nonsense from cellFrameAtRow:column: on Leopard
  • Previous by thread: Re: Bold and Italic For Dictionary Font Attributes (Hillegass Chapter 20, Challenge 2)
  • Next by thread: Interior pointer accessor list
  • Index(es):
    • Date
    • Thread