Skip to content

Instantly share code, notes, and snippets.

@brunogama
Created June 14, 2012 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunogama/2932936 to your computer and use it in GitHub Desktop.
Save brunogama/2932936 to your computer and use it in GitHub Desktop.
Literals
//
// 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;
}
@brunogama
Copy link
Author

for more literals

LLVM 3.1 Documentation http://clang.llvm.org/docs/ObjectiveCLiterals.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment