Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat does the Asterisk * mean in Objective-C?
    primarykey
    data
    text
    <p>Is it true, that the Asterisk always means "Hey, that is a pointer!" And an Pointer always holds an memory adress?</p> <p>(Yes I know for the exception that a * is used for math operation)</p> <p>For Example: </p> <pre><code>NSString* myString; </code></pre> <p>or</p> <pre><code>SomeClass* thatClass; </code></pre> <p>or</p> <pre><code>(*somePointerToAStruct).myStructComponent = 5; </code></pre> <p>I feel that there is more I need to know about the Asterirsk (*) than that I use it when defining an Variable that is a pointer to a class.</p> <p>Because sometimes I already say in the declaration of an parameter that the Parameter variable is a pointer, and still I have to use the Asterisk in front of the Variable in order to access the value. That recently happened after I wanted to pass a pointer of an struct to a method in a way like [myObj myMethod:&amp;myStruct], I could not access a component value from that structure even though my method declaration already said that there is a parameter (DemoStruct*)myVar which indeed should be already known as a pointer to that demostruct, still I had always to say: "Man, compiler. Listen! It IIISSS a pointer:" and write: (*myVar).myStructComponentX = 5;</p> <p>I really really really do not understand why I have to say that twice. And only in this case.</p> <p>When I use the Asterisk in context of an NSString* myString then I can just access myString however I like, without telling the compiler each time that it's a pointer. i.e. like using *myString = @"yep".</p> <p>It just makes no sense to me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload