• 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: NSFont errors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSFont errors


  • Subject: Re: NSFont errors
  • From: Jim Balhoff <email@hidden>
  • Date: Fri, 25 Jul 2003 15:46:37 -0400

On Friday, July 25, 2003, at 02:26 PM, Francisco Tolmasky wrote:

Ok, so I'm trying to have the font preference changed when a font gets changed in the font panel, I have changeFont: working, and it looks something like this:

- (void)changeFont:(id)sender
{
NSFont *theFont= [sender convertFont: [fontTextField font]];
[[[NSUserDefaults standardUserDefaults] setObject: theFont forKey: FontPrefKey];
//...stuff
}

But for some reason I get an error like this:

*** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value '"CGS Monaco 10.00 pt. P [] (0x01d52480) fobj=0x0029b020, spc=6.00"' of class 'NSCGSFont'.

I have no idea what's going wrong, anyone know?


You can't put an NSFont in defaults.
From <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Classes/NSUserDefaults.html#//apple_ref/occ/cl/ NSUserDefaults>:

A defaults value can be only property list objects: NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary.

I save the fontName and the pointValue (as NSNumber) in defaults. I suppose you could also archive the font as data (with NSArchiver) before putting it in defaults.

Regards,
Jim Balhoff
_______________________________________________
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.

References: 
 >NSFont errors (From: Francisco Tolmasky <email@hidden>)

  • Prev by Date: Re: FoundationKit md5/checksum
  • Next by Date: accessing data within a class
  • Previous by thread: Re: NSFont errors
  • Next by thread: Repost: Main window, key window, front window... I'm from Carbon, help me!
  • Index(es):
    • Date
    • Thread