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

  • Home
  • SEARCH
  • 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 6630063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:20:59+00:00 2026-05-25T22:20:59+00:00

I want to create a method like this: – (void) checkAndUpdateStringProperty: (NSString **) property{

  • 0

I want to create a method like this:

- (void) checkAndUpdateStringProperty: (NSString **) property{
   if (...) 
      *property = @"whatever";
}

I want to use this to pass in a property for the same class:

- (void) somewhereElse{
       ....
       [self checkAndUpdateStringProperty: &self.productName];
}

But this gives a syntax error, saying “Address of property expression requested”. Any reason why? If I replace the class property with a local variable, it works fine:

- (void) somewhereElse{
       NSString *name = nil;
       [self checkAndUpdateStringProperty: &name];
}
  • 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-25T22:21:00+00:00Added an answer on May 25, 2026 at 10:21 pm

    Properties should only ever be accessed through their getter and setter methods, with the exception of initializing and deinitializing them in the object’s init and dealloc methods (when the object is not in a fully consistent state) — accessing them any other way defeats their purpose and does not respect their attributes (retain, copy, etc.).

    The reason why it doesn’t compile is because property accessors are syntactic sugar for method calls, and you can’t take the address of the return value of a method. self.productName is identical to [self productName], and &[self productName] makes no sense.

    If you really want to do this, don’t do it with a property, do it with just a regular variable (such as a local variable or ivar), and document the semantics of your function: does the calling function need to release the returned object? Etc. For example, the various Apple methods which take an NSError** specify that the error object which is returned, if any, is an autoreleased object, so you should not release it yourself unless you also retain it.

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

Sidebar

Related Questions

I want to create a method like this: private static void AddOrAppend<K>(this Dictionary<K, MulticastDelegate>
I have two classes Order and Items I want a method like this class
I want to create a servlet method like below. In this method I want
I want to create a substr method in C++ in a string class that
I want to create a generic method to serizlize a class to text (for
I want to create a plugin called 'myPlugin'. Which method should I use and
I want to create a method like example below to make sure that a
Imagine C# code like this ISomeInterface someVar = creator.Create(typeof(SomeClass), typeof(ISomeInterface)); What should happen? Method
I want to create a method in superclass of test-class that stubs some commonly
I want to create a method sum that I can call on different types,

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.