<main.m>
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "Maxnum.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
// return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
int num1 = 330;
int num2 = 98;
int ret;
void (^simpleBlock)(void) = ^{
NSLog(@"This is a block");
};
simpleBlock();
int (^mybox)(void) = ^ {
return 100;
};
int mynum;
mynum = mybox();
NSLog(@"my num is :%d", mynum);
double (^myarea)(double,double) = ^(double firstvalue, double secondvalue){
return firstvalue * secondvalue;
};
double myref = myarea(34,55);
NSLog(@"myref is :%f",myref);
Big *maxnum = [[Big alloc] init];
ret = [maxnum Max:num1 andNum2:num2];
NSLog(@"my big number is :%d", ret);
return ret;
};
}
2017-12-05 00:03:51.855979+0800 MyOCtestbc[72326:22235781] This is a block
2017-12-05 00:03:51.857582+0800 MyOCtestbc[72326:22235781] my num is :100
2017-12-05 00:03:51.857887+0800 MyOCtestbc[72326:22235781] myref is :1870.000000
2017-12-05 00:03:51.858448+0800 MyOCtestbc[72326:22235781] my big number is :330
Maxnum.h
#import <Foundation/Foundation.h>
@interface Big:NSObject
- (int)Max :(int)num1 andNum2:(int)num2;
@end
Maxnum.m
#import <Foundation/Foundation.h>
#import "Maxnum.h"
@implementation Big
- (int)Max:(int)num1 andNum2:(int)num2 {
int result;
if (num1 > num2) {
result = num1;
} else {
result = num2;
}
return result;
}
@end