7k views
Hola mundo para el iPhone
El hola mundo más básico que encontrado para el iPhone. Lo encontré en un post de O'Reilly.
Makefile:
GNU make
- CC=arm-apple-darwin-cc
- LD=$(CC)
- LDFLAGS=-lobjc -framework CoreFoundation -framework Foundation -framework UIKit -framework LayerKit -framework CoreGraphics
- all: SampleApp
- SampleApp: mainapp.o SampleApp.o
- $(LD) $(LDFLAGS) -v -o $@ $^
- %.o: %.m
- $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
- clean:
- rm -f *.o SampleApp
mainapp.m
Objective-C
- #import <UIKit/UIKit.h>
- #import "SampleApp.h"
- int main(int argc, char **argv)
- {
- return UIApplicationMain(argc, argv, [SampleApp class]);
- }
SampleApp.h
Objective-C
- #import <CoreFoundation/CoreFoundation.h>
- #import <Foundation/Foundation.h>
- #import <UIKit/CDStructures.h>
- #import <UIKit/UIWindow.h>
- #import <UIKit/UIView-Hierarchy.h>
- #import <UIKit/UIHardware.h>
- #import <UIKit/UIKit.h>
- #import <UIKit/UIApplication.h>
- #import <UIKit/UITextView.h>
- #import <UIKit/UIView.h>
- @interface SampleApp : UIApplication {
- UIView *mainView;
- UITextView *textView;
- }
- @end
SampleApp.m
Objective-C
- #import "SampleApp.h"
- @implementation SampleApp
- - (void) applicationDidFinishLaunching: (id) unused
- {
- UIWindow *window;
- struct CGRect rect = [UIHardware fullScreenApplicationContentRect];
- rect.origin.x = rect.origin.y = 0.0f;
- window = [[UIWindow alloc] initWithContentRect: rect];
- mainView = [[UIView alloc] initWithFrame: rect];
- textView = [[UITextView alloc]
- initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)];
- [textView setEditable:YES];
- [textView setTextSize:14];
- [window orderFront: self];
- [window makeKey: self];
- [window _setHidden: NO];
- [window setContentView: mainView];
- [mainView addSubview:textView];
- [textView setText:@"Hello World"];
- }
- @end
Submitted by miguelSantirso over 2 years ago — last modified less than a minute ago