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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:29:06+00:00 2026-06-10T11:29:06+00:00

Im trying to learn obj-c and here’s something I dont understand. I know some

  • 0

Im trying to learn obj-c and here’s something I dont understand. I know some c# so could someone try to explain this in in a c#y-way I maybe could understand it better 🙂

#import <Foundation/Foundation.h> @interface Car : NSObject
@interface Car : NSObject
  {
  int year;
  NSString *make;
  NSString *model;
  }

  **- (void) setMake:(NSString *) aMake andModel:(NSString *) aModel andYear: (int) aYear;**
  - (void) printCarInfo;
  - (int) year;
@end

I think i understand the declarations of the variables, but i dont get it for the metod(s?). Can someone explain what this do (bold code)?

  • 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-10T11:29:08+00:00Added an answer on June 10, 2026 at 11:29 am

    The concept which is missing from your learning is “selector”. It’s essentially like “decorating” a method signature with more semantics than you can get with parenthesized parameter-passing. We tend to use descriptive, sentence-like “selectors” for our method prototypes. As an example, consider this basic function:

    void function setDimensions(int width, int height);
    

    in Objective-C, we would write it like this:

    - (void) setWidth:(int) newWidth height:(int) newHeight;
    

    and the “selector” (which is a first-class concept in Objective-C) is setWith:height: (including the colons, but not anything else). That’s the thing that uniquely identifies that method on that class.

    Calling that method happens at runtime when you send a message to that object with arguments placed after the colons in the selector. So a message has three essential components: a recipient, a selector, and the well-placed arguments:

    [anObject setWidth: 1024 height: 768];
    

    Here, anObject is the recipient, setWidth:height: is the selector (helps the runtime find the method), and the arguments are: newWidth = 1024; newHeight = 768;.

    Then in the implementation of the method, simply use newWidth and newHeight like you would expect:

    - (void) setWidth:(int) newWidth height:(int) newHeight; {
        self.width = newWidth; // 1024
        self.height = newHeight; // 768
    }
    

    It may seem awkward and superfluous at first, but after you get used to it, you will prefer it and find yourself writing longer, more semantic function names in other languages.

    The concepts associated with selectors are all better understood when learned along with some of the basics of the Objective-C runtime, specifically the concept of “sending messages” (instead of “calling methods”) and the fact that at runtime, not compile-time the actual method is looked-up based on the selector you use in the message. The fact that this happens at runtime gives remarkable flexibility for highly dynamic architectures.

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

Sidebar

Related Questions

I'm trying to port the as3delaunay library to Obj-C (for fun and to learn
Trying to learn a bit about PDO and is going through this tutorial .
Trying to learn MVP pattern with C#... Does anyone know of any particularly good
im trying to learn delegates and events in c#, i understand that an event
Im trying to learn a bit about c++ and have run in to some
Trying to learn jquery here so I took a regular javascript snippet that loops
Trying to learn some R after doing mostly Haskell for rather a long time
I am trying to learn some PHP using the book titled PHP for Absolute
sorry - I know this is dead easy stuff, but I'm just trying to
I'm trying to learn Lisp but I got stuck by this example (you can

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.