Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6193317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:05:55+00:00 2026-05-24T03:05:55+00:00

In my program, I am assigning a value to a property in the init

  • 0

In my program, I am assigning a value to a property in the init method. I later use this property in response to an event.

Given a property named Object; why does the synthesized setter [self setObject:obj] work, but Object = obj give an Invalid Selector exception? Is it because the mutator adds one to the reference count on obj?

Edit: Here is more code, to give context. When I say “work” above, I mean run without errors.

Here is the initialization of the object(A View Controller) which has the property in it:

Note: All properties are declared as (nonatomic, retain).

@synthesize _Kiosk;

....

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil andKiosk: (Kiosk*) kiosk
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        [self set_Kiosk:kiosk]; //This work witout error. _kiosk = kiosk Fails at point below.
    }
    return self;
}

....

- (IBAction) ActionPressed:(id)sender
{
    [_CompanyName setText: [_Kiosk _CompanyName]];  //Failure happens here
}

And here is the method call that initializes this View Controller:

@synthesize _Kiosk;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [[UIApplication sharedApplication] setStatusBarHidden:true withAnimation:UIStatusBarAnimationFade];

    _Kiosk = [[Kiosk alloc] init];
    self.window.rootViewController = [_KioskViewController initWithNibName:@"iPadKioskView" bundle:nil andKiosk: _Kiosk];

    [_Kiosk release];
    [self.window makeKeyAndVisible];
    return YES;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:05:55+00:00Added an answer on May 24, 2026 at 3:05 am

    @property basically just declares two methods: setFoo: and foo. @synthesize will create the method bodies for those methods, which will correctly retain the new value and release the old one.

    Assigning directly to the instance variable, however, doesn’t call those accessor methods. It just makes the pointer point to a new object. If you’re going to manually set the instance variable, then you need to make sure to correctly retain new value and release the old one.

    Note that [self setFoo:someFoo] and self.foo = someFoo will both call the accessor method, while foo = someFoo just sets the instance variable directly, bypassing your setter method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Strange program hang, what does this mean in debug? After attaching windbg I found
From Python docs: sys.excepthook(type, value, traceback) This function prints out a given traceback and
I am assigning values in a C++ program out of the bounds like this:
So I have this program for assigning people to projects. In my database I
I've singled out a failure on my program that prevents me from assigning a
What program can I use to decompile a class file? Will I actually get
Valgrind reports a memory leak when assigning a value to a string. I used
First of all: This is not a question about how to make a program
this is followup to this question : Assigning 1 line of a txt file
For the very common case of assigning a value to a variable based on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.