• 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: Getters/Setters via Property/Synthesize...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getters/Setters via Property/Synthesize...


  • Subject: Re: Getters/Setters via Property/Synthesize...
  • From: Keary Suska <email@hidden>
  • Date: Tue, 03 Jun 2014 06:54:44 -0600

On Jun 2, 2014, at 8:31 PM, Peters, Brandon wrote:

> Is there anything that could cause the getter and setter not to be generated properly? I have my properties declared:
>
> @property (assign) float mass, appliedForce;
>
> In the implementation file:
>
> @synthesize mass = _mass;
>
> Then in the AppController:
>
> -(IBAction)updateMass:(id)sender
> {
>    [_simulationView setMass:[sender floatValue]];
>    //[_massDisplay setFormatter:_numberFormatter];
>    NSLog(@"Mass: %f", [_simulationView mass]);
>    [_massDisplay setFloatValue:[_simulationView mass]]; // [A]
> }
>
> If I replace [_massDisplay setFloatValue:[_simulationView mass]] with [_massDisplay setFloatValue:[sender floatValue]], the value displays in the text field in the panel. But with the former I get zero.

What does the NSLog() in -updateMass: show? Also, with what Graham mentions, change the NSLog to:
	NSLog(@"%@ Mass: %f", _simulationView, [_simulationView mass]);
to make sure that it is not nil at the time you need it. Simply not being nil at initialization doesn't mean anything.

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


  • Follow-Ups:
    • Re: Getters/Setters via Property/Synthesize...
      • From: "Peters, Brandon" <email@hidden>
References: 
 >Getters/Setters via Property/Synthesize... (From: "Peters, Brandon" <email@hidden>)

  • Prev by Date: iOS - NSOperation/NSOperationQueue Question
  • Next by Date: Re: Understanding ARC
  • Previous by thread: Re: Getters/Setters via Property/Synthesize...
  • Next by thread: Re: Getters/Setters via Property/Synthesize...
  • Index(es):
    • Date
    • Thread