[Project] demo [cmd] ls -R
.:
GNUmakefile
main
Readme.md
r.sh
src
./src:
Fraction.h
Fraction.m
main.m
Person.h
Person.m
Person.h
#import <Foundation/Foundation.h>
#import <stdio.h>
@interface Person:NSObject{
int age;
int sex;
}
- (void)getAge;
@end
Person.m
#import "Person.h"
@implementation Person
- (void)getAge {
printf("%d\n", age);
}
@end
Fraction.h
#import <Foundation/Foundation.h>
@interface Fraction : NSObject {
@protected
int numerator;
int denominator;
}
- (void)print;
- (id)set:(int)n over:(int)d;
- (id)init;
@end
Fraction.m
#import "Fraction.h"
@implementation Fraction
- (void)print {
NSLog(@"print");
}
- (id)init {
self = [super init];
if (self != nil) {
self->denominator = 1;
self->numerator = 1;
}
return self;
}
- (void)set:(int)n over:(int)d {
self->denominator = d;
self->numerator = n;
}
@end
main.m
#import "Fraction.h"
#import "Person.h"
#import <AppKit/AppKit.h>
#pragma mark main1
int main1() {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
Fraction *f = [Fraction init];
NSLog(@"fuc");
NSSet *set1 = [[NSSet alloc] initWithObjects:@"one", @"two", nil];
NSLog(@"fuck you");
NSArray *arr1 = nil;
NSSet *set2 = [NSSet new];
NSString *str = @"hell world";
NSLog(str);
int i = 2;
NSLog(@"%d", i);
printf("%d\n", i);
[f release];
[pool drain];
return 0;
}
#pragma mark struct Hello
typedef struct Hello {
int a;
} Hello;
void sayHello(struct Hello *me) {
printf("a: %d\n", me->a);
printf("yas\n");
}
#define PI 3.14
#pragma mark test case
void test1() {
int score = 10;
if (score < 20) {
NSLog(@"static load failed");
} else if (score >= 60) {
NSLog(@"nice");
} else {
NSLog(@"full score");
}
}
#pragma mark
int main2() {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
Person *per1 = [[Person alloc] init];
per1->age = 1;
[per1 getAge];
Hello h1;
h1.a = 1;
sayHello(&h1);
printf("PI: %d\n", PI);
printf("\n*************test code***************\n");
test1();
[pool drain];
return 0;
}
#pragma mark
int main() {
CREATE_AUTORELEASE_POOL(pool);
printf("yas\n");
RELEASE(pool);
}
GNUmakefile
GNUSTEP_MAKEFILES = /usr/share/GNUstep/Makefiles
SRC_DIR = ./src
include ${GNUSTEP_MAKEFILES}/common.make
APP_NAME = main
main_HEADERS = $(SRC_DIR)/Fraction.h $(SRC_DIR)/Person.h
main_OBJC_FILES = $(SRC_DIR)/main.m $(SRC_DIR)/Fraction.m $(SRC_DIR)/Person.m
main_RESOURCE_FILES =
include ${GNUSTEP_MAKEFILES}/application.make
r.sh
#!/bin/sh
make
echo -e "\n\n\n"
echo "************************************"
echo "************************************"
echo "************************************"
openapp ./main.app
echo -e "\n\n\n"
echo "***************** start cleaning **************************"
make clean
[COMMAND] ./r.sh