diff options
Diffstat (limited to 'examples/cross_calculator/ios/src')
-rw-r--r-- | examples/cross_calculator/ios/src/AppDelegate.h | 7 | ||||
-rw-r--r-- | examples/cross_calculator/ios/src/AppDelegate.m | 39 | ||||
-rw-r--r-- | examples/cross_calculator/ios/src/cross-calculator-Prefix.pch | 10 | ||||
-rw-r--r-- | examples/cross_calculator/ios/src/main.m | 13 |
4 files changed, 69 insertions, 0 deletions
diff --git a/examples/cross_calculator/ios/src/AppDelegate.h b/examples/cross_calculator/ios/src/AppDelegate.h new file mode 100644 index 000000000..a5a8b3852 --- /dev/null +++ b/examples/cross_calculator/ios/src/AppDelegate.h @@ -0,0 +1,7 @@ +#import <UIKit/UIKit.h> + +@interface AppDelegate : UIResponder <UIApplicationDelegate> + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/examples/cross_calculator/ios/src/AppDelegate.m b/examples/cross_calculator/ios/src/AppDelegate.m new file mode 100644 index 000000000..d39a08b65 --- /dev/null +++ b/examples/cross_calculator/ios/src/AppDelegate.m @@ -0,0 +1,39 @@ +#import "AppDelegate.h" + +#import "backend.h" + +@implementation AppDelegate + +@synthesize window = _window; + +- (void)dealloc +{ + [_window release]; + [super dealloc]; +} + +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] + bounds]] autorelease]; + // Override point for customization after application launch. + self.window.backgroundColor = [UIColor whiteColor]; + [self.window makeKeyAndVisible]; + + // Call nimrod code and store the result. + const int a = 3; + const int b = 12; + const int c = myAdd(a, b); + + // Add a label to show the results of the computation made by nimrod. + UILabel *label = [[UILabel alloc] initWithFrame:self.window.bounds]; + label.textAlignment = UITextAlignmentCenter; + label.text = [NSString stringWithFormat:@"myAdd(%d, %d) = %d", a, b, c]; + [self.window addSubview:label]; + [label release]; + + return YES; +} + +@end diff --git a/examples/cross_calculator/ios/src/cross-calculator-Prefix.pch b/examples/cross_calculator/ios/src/cross-calculator-Prefix.pch new file mode 100644 index 000000000..2f331ed43 --- /dev/null +++ b/examples/cross_calculator/ios/src/cross-calculator-Prefix.pch @@ -0,0 +1,10 @@ +#import <Availability.h> + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iOS SDK 3.0 and later." +#endif + +#ifdef __OBJC__ + #import <UIKit/UIKit.h> + #import <Foundation/Foundation.h> +#endif diff --git a/examples/cross_calculator/ios/src/main.m b/examples/cross_calculator/ios/src/main.m new file mode 100644 index 000000000..7866684fe --- /dev/null +++ b/examples/cross_calculator/ios/src/main.m @@ -0,0 +1,13 @@ +#import <UIKit/UIKit.h> + +#import "AppDelegate.h" +#import "backend.h" + +int main(int argc, char *argv[]) +{ + @autoreleasepool { + NimMain(); + return UIApplicationMain(argc, argv, nil, + NSStringFromClass([AppDelegate class])); + } +} |