Skip to content

Instantly share code, notes, and snippets.

@DmitrySkiba
Created January 18, 2012 17:04
Show Gist options
  • Save DmitrySkiba/1634076 to your computer and use it in GitHub Desktop.
Save DmitrySkiba/1634076 to your computer and use it in GitHub Desktop.
Example of app that Itoa supports
#import <Foundation/Foundation.h>
#import <CoreFoundation/CoreFoundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
/////////////////////////////////////////////////////////////////////
@interface ApplicationDelegate: NSObject<UIApplicationDelegate> {
@private UIWindow* m_window;
@private UILabel* m_label;
@private UIButton* m_button;
}
@end
@implementation ApplicationDelegate
-(void)dealloc {
[m_window release];
[m_label release];
[m_button release];
[super dealloc];
}
-(void)onSayHello:(id)sender {
if (m_label) {
return;
}
m_label=[[UILabel alloc] init];
m_label.frame=CGRectMake(0,0,150,50);
m_label.center=CGPointMake(m_window.center.x,m_window.center.y-50);
m_label.textAlignment=UITextAlignmentCenter;
#ifdef ANDROID
m_label.text=@"Hello, Android!";
#else
m_label.text=@"Hello, iOS!";
#endif
[m_window addSubview:m_label];
}
-(void)applicationDidFinishLaunching:(UIApplication*)application {
CGRect bounds=[[UIScreen mainScreen] bounds];
UIWindow* window=[[UIWindow alloc] initWithFrame:bounds];
window.backgroundColor=[UIColor darkGrayColor];
UIButton* button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame=CGRectMake(0,0,150,50);
button.center=CGPointMake(window.center.x,window.center.y+50);
[button setTitle:@"Say hello" forState:UIControlStateNormal];
[button addTarget:self action:@selector(onSayHello:) forControlEvents:UIControlEventTouchUpInside];
[window addSubview:button];
m_button=button;
[window makeKeyAndVisible];
m_window=window;
}
@end
/////////////////////////////////////////////////////////////////////
int main(int argc,char* argv[]) {
NSAutoreleasePool* pool=[[NSAutoreleasePool alloc] init];
UIApplicationMain(argc,argv,NULL,@"ApplicationDelegate");
[pool release];
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment