What is Objective C Keyword id ?

By | March 6, 2011

Hi,

Objective C uses a special keyword ‘id’.
Let’s see what it is.
Objective C -id- is actually a ‘pointer to an object’. That is ‘id’ can hold a pointer to any objective c object. It doesn’t matter the object’s class.
eg:

NSString *myString = @"Coderz Heaven!";
id newString;
NSString *tempString;
newString=myString;
tempString=newString;

That’s it! It will work out with using ‘id’ keyword. Compiler simply thinks ‘you know what you are doing!’

A word of caution : Remember not to use * while creating id objects! Because that type already know it’s a pointer!

One thought on “What is Objective C Keyword id ?

  1. Diedre Marty

    I’d come to settle with you one this subject. Which is not something I typically do! I really like reading a post that will make people think. Also, thanks for allowing me to speak my mind!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *