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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:49:06+00:00 2026-05-14T23:49:06+00:00

I just started with Objective-C and I would like to understand the meaning of

  • 0

I just started with Objective-C and I would like to understand the meaning of the following lines of code as I see it everywhere in objective-c but I’m not quite getting it 100%:

- (id)initWithName:(NSString *)name;

I understand that the above line is a instance method passing one argument, what I don’t understand is (NSString *)name.

another example is:

-(NSString *)name;

or

person.height = (NSObject *)something;

Thanks for your help

  • 1 1 Answer
  • 3 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-14T23:49:06+00:00Added an answer on May 14, 2026 at 11:49 pm

    In this line:

    - (id)initWithName:(NSString *)name;
    

    (NSString *) is simply the type of the argument – a string object, which is the NSString class in Cocoa. In Objective-C you’re always dealing with object references (pointers), so the “*” indicates that the argument is a reference to an NSString object.

    In this example:

    person.height = (NSObject *)something;
    

    something a little different is happening: (NSObject *) is again specifying a type, but this time it’s a “type casting” operation — what this means is to take the “something” object reference (which could be an NSString, NSNumber, or …) and treat it as a reference to an NSObject.


    update –
    When talking about Objective-C objects (as opposed to primitive types like int or float), everything’s ultimately a pointer, so the cast operation means “take this pointer an X and treat it as if it’s pointing to a Y“. For example, if you have a container class (like NSArray) that holds generic NSObjects, but you know that the the objects are actually strings, you might say:

    NSString *myString = (NSString *)[myArray objectAtIndex:0];
    

    which means “retrieve the first object from the array, treating it as a string”.

    The cast is not actually converting the value, it’s just a way of saying to the compiler “hey, I know that I’m assigning an X to a Y here, so don’t give me a warning about it”.

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

Sidebar

Related Questions

I have just started programming in Objective-C, I understand it only partially supports method
I just started Objective-C recently, and this has once again gotten me to the
I'm just getting started with Objective-C and I'm writing a simple application. I made
I have just started learning Objective-C, I am reading Programming in Objective-C 3rd Edition
I'm coming from C# development and just started to learn Objective-C and Xcode 4.
I just started learning Objective-C and OOP ... so I have very stupid question
I've just started learning Objective C and getting a bit stumped with arrays. Basically,
I just started to learn Objective c. Now i want a under title (small
Having just started with Objective-C, this might be a pretty basic question. In objective-c,
I am a novice in Programming and have just started Objective C. I have

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.