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 7871565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:56:43+00:00 2026-06-03T01:56:43+00:00

I want to create a property in a category so I can use dot

  • 0

I want to create a property in a category so I can use dot notation with the accessors. The reason I want to do this is so I can refactor some existing code that references properties of an NSMangedObject. Then I will put the category accessor methods between the outside callers and the NSManagedObject properties that they relate to. (I don’t want to replace the current dot-notation usage with messaging, because I use dot notation through a very large project.)

I experimented a little inside the category interface with a property declaration like this:

@property NSString* details;

This results in a compiler warning (It didn’t like the default assign attribute.)

Since there is no ivar directly tied to the property, there is no sense in adding the attribute of retain or copy.

Next, I just left out the @property line and added accessors to the interface and implementation files.

- (void) setDetails:(NSString*)details;
- (NSString*) details;

I compiled and ran the code. I tested the methods using dot notation. I could see that the accessors could be successfully used without error and without the compiler complaining.

What I have read about dot-notation tells me that if I set up a property a certain way, I can use dot notation. But I am not setting up a property conforming to that requirement. But it appears that I can still use dot notation.

Is there anything wrong with this approach? Is there a specification that defines how and when dot notation accessors can be used?

  • 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-06-03T01:56:45+00:00Added an answer on June 3, 2026 at 1:56 am

    The dot notation is intended to be used for declared property access, but in fact the compiler handles it loosely enough that any no-argument method can be used if you’re not assigning to the result:

     aString.lowercaseString;
     aNumber.intValue;
     aDict.allKeys;
    

    Likewise, the compiler will allow you to use a dot-syntax expression as if it were an lvalue, if there is a one-argument method of the form set<uppercase name>: available on the object:

    aString.string = @"Amazing";
    aWindow.alphaValue = 0.45;
    

    even if that name wasn’t declared with the @property syntax.

    Blah, blah, I guess you knew that already. The only relevant documentation I can dig up at the moment is this sentence from TOCPL:

    When used with objects, however, dot syntax acts as “syntactic sugar”—it is transformed by the compiler into an invocation of an accessor method.

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

Sidebar

Related Questions

I want to create an attached property that can be used with this syntax:
I want to create a property grid like this: Ext JS Property Grid demo
I want to create a property grid (the one which is similar to the
I want to create a custom property on one of my entities mapped from
I want to create an object with a non-enumerable property(a property that does not
I am curious on how to create a property that can be translated by
I want to create a column/property in my Model that is a GUID? What
Using Python I want to create a property in a class, but having the
I have a user control and I want to create a property of type
I want to create an object property that re-calculates it's value each time it

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.