Created
June 14, 2012 21:03
-
-
Save brunogama/2932936 to your computer and use it in GitHub Desktop.
Literals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.m | |
// Literals | |
// | |
// Created by Bruno Gama on 14/06/12. | |
// Copyright (c) 2012 Bruno Gama. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) | |
{ | |
@autoreleasepool { | |
__block id num = @ 5.1, | |
arr = @ [@"a", @"b", @"c", @1, @2., @.3], | |
dic = @{ @"hi" : num, @"sup" : arr }; | |
#define _c(theString) \ | |
[[(theString) class] description] | |
// Console output: | |
// 2012-06-14 21:30:35.296 Literals[8203:403] key=hi (__NSCFConstantString), obj=5.1 (__NSCFNumber) | |
// 2012-06-14 21:30:35.298 Literals[8203:403] key=sup (__NSCFConstantString), obj=( | |
// a, | |
// b, | |
// c, | |
// 1, | |
// 2, | |
// "0.3" | |
// ) (__NSArrayI) | |
// | |
[dic enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { | |
NSLog(@"key=%@ (%@), obj=%@ (%@)", key, _c(key), obj, _c(obj)); | |
}]; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for more literals
LLVM 3.1 Documentation http://clang.llvm.org/docs/ObjectiveCLiterals.html