Don_Mag icon

Macro / Block / Function / etc

Don_Mag | PRO | 10/28/21 05:19:11 PM UTC | 0 ⭐ | 10810 👁️ | Never ⏰ | []
Objective C |

0 B

|

None

|

0 👍

/

0 👎

//
//  main.m
//  ScratchObjC
//
//  Created by Don Mag on 3/17/20.
//  Copyright © 2020 Don Mag. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
 
// MACRO definition
#define MACROSUM(a, b) a + b;
 
// BLOCK declaration
int (^BLOCKSUM)(int, int) = ^(int a, int b) {
    return a + b;
};
 
// Function
int functionSum(int a, int b) {
    return a + b;
}
 
int main(int argc, char * argv[]) {
    
    int x = 0;
    
    x = 1 + 2;
    
    NSLog(@"Assignment result: %d", x);
    
    x = functionSum(3, 4);
    
    NSLog(@"Function result: %d", x);
    
    x = MACROSUM(5, 6);
    
    NSLog(@"Defined Macro result: %d", x);
    
    x = BLOCKSUM(7, 8);
    
    NSLog(@"Declared Block result: %d", x);
    
    x = ^(int a, int b) {
        return a + b;
    }(9, 10);
    
    NSLog(@"Inline Block result: %d", x);
    
    NSString * appDelegateClassName;
    @autoreleasepool {
        // Setup code that might create autoreleased objects goes here.
        appDelegateClassName = NSStringFromClass([AppDelegate class]);
    }
    return UIApplicationMain(argc, argv, nil, appDelegateClassName);
}
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎