#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int intVar = 100;
long int longIntVar = 131071100L;
float floatVar = 331.79;
double doubleVar = 8.44e+11;
long double longDoubleVar = 1.234e+7L;
char charVar = 'W';
NSLog(@"intVar = %i", intVar);
NSLog(@"longIntVar = %li", longIntVar);
NSLog(@"floafVar = %f", floatVar);
NSLog(@"doubleVar = %e", doubleVar);
NSLog(@"longDoubleVar = %Le", longDoubleVar);
NSLog(@"doubleVar = %g", doubleVar);
NSLog(@"charVar = %c", charVar);
[pool drain];
return 0;
}
Then launch the console and press Build & Go:
There is one special type in Objective-C. This is id. This type is used to store objects of any type. I think it is something like void*. So it is possible to write the following code:
id everything = (id)intVar;
NSLog(@"variable of id type = %i", everything);
No comments:
Post a Comment