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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:00:41+00:00 2026-05-30T02:00:41+00:00

I’m a kind of self-programmer-made-man, so I’m missing some basic knowledge from time to

  • 0

I’m a kind of self-programmer-made-man, so I’m missing some basic knowledge from time to time.

That’s why I’m unable to really define well the topic of my question, because I don’t know how to name it and how it works (but I know answer will seem trivial to many of you). When you know what’s you’re looking for it’s a lot easier to find answers.

In objective-c, I can see lines of code like this :

aClassName *myObject = (aClassName *)[NSEntityDescription insertNewObjectForEntityForName:@"aClassName" inManagedObjectContext:app.managedObjectContext];

What’s bother me is that (aClass *) part. What’s this ?

I know/feel it’s related to very basic knowledge but I can’t name it so I can’t find it.

My guess (and that’s how I use it up to now) is that’s used for calling class methods (+) but i’m not sure of it and it may be more deep that what I understand.

Thanks for any explanation.

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

    It’s a cast, in this case a down cast (even because up casts are implicit).

    A cast is an operation that the developer does while writing the code to hint the compiler that a type is narrower than the one the compiler is thinking about.

    Think about the following situation:

    Class *a = [[Subclass alloc] init];
    Subclass *b = a;
    

    (assume that Subclass is a subclass of Class)

    This won’t compile because a is statically defined with a type which is not contained in Subclass. But the assignment wouldn’t create any problem dynamically because a is used to store a Subclass object in practice.

    So what you do? You place a cast Subclass *b = (Subclass*)a; to tell the compiler “trust me and ignore typechecking that assignment, I assert that it will be valid a runtime”, and you automagically remove the compilation error. Forcing this behaviour of course removes type safety from your code, so you must know what you are doing.

    Of course to understand the meaning of a cast in this situation you must at least know about inheritance and objects..

    In your specific situation the return type of the method +(id)insertNewObjectForEntityForName:... is id, which is the least specific kind of object in ObjectiveC, it always needs to be casted to something if not stored just like a plain id

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.