• 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: KVC broken in 10.4.4 on Intel?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVC broken in 10.4.4 on Intel?


  • Subject: Re: KVC broken in 10.4.4 on Intel?
  • From: Scott Ellsworth <email@hidden>
  • Date: Sun, 29 Jan 2006 20:53:34 -0800


On Jan 29, 2006, at 6:07 PM, Da Woon Jung wrote:

2006/1/30, Shawn Erickson wrote:

On Jan 28, 2006, at 6:30 PM, Da Woon Jung wrote:

Hi,

On my PowerBook G4 (PPC), the following works fine:

- (void)setFaintestVisible: (float)aValue
{
  NSLog(@"%f", aValue);
}

//...elsewhere, inside a method...

[self setValue:[NSNumber numberWithFloat: 7.9f]
forKey:@"faintestVisible"];

// Prints 7.900000

In the above why not just do...

[self setFaintestVisible:7.9f];

If someone is using KVO they will still get notified of the change if
you use your accessor directly.

That would defeat the purpose somewhat of using KVC.

Not for the example you showed us. Your accessor only takes a float, not an NSNumber, and NSNumbers do not autoconvert to floats. (If I am wrong about that, I would love a doc pointer, but ISTR that there is no reason for the above to work when sent an NSNumber*. The calling conventions on Intel are different than on PPC, which brings out the above behavior.


I suspect that

[self setValue:[[NSNumber numberWithFloat: 7.9f] floatValue]
forKey:@"faintestVisible"];

would get the results you expect, as that is the accessor you are wrote, or changing the accessor to take the values you are actually sending it, like


- (void)setFaintestVisible: (id)aValue
{
  NSLog(@"%@", aValue);
}

would work as well.

[self takeValue: [defaultsDictionary objectForKey: key] forKey: key];

Also, why _not_ use setValue:forKey:? Do you have any _set<key> setters in your code?


Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: KVC broken in 10.4.4 on Intel?
      • From: Da Woon Jung <email@hidden>
References: 
 >KVC broken in 10.4.4 on Intel? (From: Da Woon Jung <email@hidden>)
 >Re: KVC broken in 10.4.4 on Intel? (From: Shawn Erickson <email@hidden>)
 >Re: KVC broken in 10.4.4 on Intel? (From: Da Woon Jung <email@hidden>)

  • Prev by Date: Re: threads or processes?
  • Next by Date: Re: Trouble refreshing iCal
  • Previous by thread: Re: KVC broken in 10.4.4 on Intel?
  • Next by thread: Re: KVC broken in 10.4.4 on Intel?
  • Index(es):
    • Date
    • Thread