2014년 10월 9일 목요일

@ 매크로


1.
    NSString *string = @"<#string#>"

2.  
    id express = @(<#expression#>)

  (ex)
    NSInteger idx = 40;
    NSString *idxString = [@(idx) stringValue];

3.    
    NSArray *array =  @[<#objects, ...#>]

4.    
    @autoreleasepool {
        <#statements#>
    }

5.    
    char[] chars =  @encode(<#type-name#>)

6.    
    Protocol *protocol = @protocol(<#protocol-name#>)

7.    
    SEL sel = @selector(<#selector#>)

8.    
    @throw <#expression#>
    
9.
    NSDictonary *dic = @{<#key#>: <#object, ...#>}
    
10.
    @try {
        <#Code that can potentially throw an exception#>
    }
    @catch (NSException *exception) {
        <#Handle an exception thrown in the @try block#>
    }
    @finally {
        <#Code that gets executed whether or not an exception is thrown#>

    }

11. structure

    CGSize theSize = {
        .width = 100.f,
        .height = 100.f,
    };
    
    CGRect theRect = {
        {.x = 10.f, .y= 10.f},
        {.width = 200.f, .height = 200.f}
    };

댓글 없음:

댓글 쓰기