Tuesday, February 26, 2013

This ain't so DIfferent.


One of the most important thing is printing out a message.
In C++, we use:
std::cout.

In Objective-C we use:
NSLog(@"hello");

NSLog - This is used to tell compiler that what follows goes to the output window.
@ sign is an indicator to the compiler that this code is not regular C but Objective-C.


Variable declaration:

This is quite same as C.

int iVar;
float fVar;
double dVar;

Calculations are done in the same way that you will do in any language:
int iResult = 10 * 5;

When outputting this iResult, we will use:

NSLog (@"the result is : %i ", iResult);

Sound familiar??
The use of "%i" as a placeholder is used in C as well.

No comments:

Post a Comment