• 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: Wed, 28 Oct 2009 16:02:33 -0400

On Tue, Oct 27, 2009 at 3:39 PM, Jens Alfke <email@hidden> wrote:
>
> On Oct 27, 2009, at 4:59 AM, Chunk 1978 wrote:
>
>> attributes = [[NSMutableDictionary alloc] init];
>>
>> [attributes setObject:[NSFont fontWithName:@"Helvetica" size:75] forKey:
>> NSFontAttributeName];
>>
>> [attributes setObject:[NSColor redColor] forKey:
>> NSForegroundColorAttributeName];
>>
>> [attributes setObject:shadow forKey:NSShadowAttributeName];
>
> You can change this to
>
> attributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
>        NSFontAttributeName, [NSFont fontWithName:@"Helvetica" size:75],
>        NSForegroundColorAttributeName, NSColor redColor],
>        NSShadowAttributeName, shadow,
>        nil];

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];

Ref: http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDictionary/initWithObjectsAndKeys:
("First the key for firstObject, then a null-terminated list of
alternating values and keys.").

No doubt this was part of the motivation for creating the MYUtilities
library. I'll have to check it out myself.

-- 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

  • Follow-Ups:
    • Re: Bold and Italic For Dictionary Font Attributes (Hillegass Chapter 20, Challenge 2)
      • From: Graham Cox <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>)

  • Prev by Date: Re: Programmatically invoking double-click bindings on NSTableView
  • Next by Date: Re: Multithreading NSBezierPath creation and stroking. Measuring performance
  • Previous by thread: Re: Bold and Italic For Dictionary Font Attributes (Hillegass Chapter 20, Challenge 2)
  • Next by thread: Re: Bold and Italic For Dictionary Font Attributes (Hillegass Chapter 20, Challenge 2)
  • Index(es):
    • Date
    • Thread