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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:56:55+00:00 2026-05-25T02:56:55+00:00

Lets say a class has a plain old no-args method declared like this: –

  • 0

Lets say a class has a plain old no-args method declared like this:

- (NSString *)responseString;

There are two ways to call this method. Either using

string = [instance responseString];

or, with the dot syntax, like this:

string = instance.responseString;

What is the preferred way? Any reasons to avoid the last approach?


Update:
responseString is a property of the class, except it is not declared with @property. It is, by definition, an accessor method (getter). The generated code is exactly the same.

(We assume objc v2.0+ here.)

  • 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-25T02:56:56+00:00Added an answer on May 25, 2026 at 2:56 am

    My preferred way is always to use the former because I think dot notation is an abomination that should never have been added to the language.

    Putting aside my (justified) prejudice for a moment, you should only use dot notation for things that are conceptually properties (i.e. they don’t necessarily have to use @property to declare them but they should be attributes of the object as opposed to operations the object performs). The name of the method in this case is a noun, so the chances are that -responseString is a property and it’s OK to use dot notation.

    An example of something it would not be appropriate to use dot notation for is NSMutableArray‘s -removeAllObjects method.

    NB: regardless of whether you use dot notation or not, it is a good idea to always use @property to declare things that are conceptually properties.

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

Sidebar

Related Questions

My ProductRepository has a method, lets say: GetAllCalculatedProducs(int categoryId) {} This method uses class
I have a class, lets say CAppPath which has a static method: public: static
Lets say I have an ActionScript class: MyClass and that class has data in
Lets say I have object Tom which has class Person. Class Person String Name
Lets say we have a sql relationship that can be modeled like this using
Lets say you have a class SomeClass which has its own implementation of toString()
Lets say there is a activerecord class called user, which is representative of user
Lets say I have a site that has a Layout with navigation. This navigation
I have a class that has a function, lets say class.php: class fun {
Let's say I have a class that has a member called data which is

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.