Empty Tutorial

From GameOver

Jump to: navigation, search

Contents

Introduction

A blank window that shows the basics of what is required for an Obj-C iPhone application.

Screenshots

Requirements

This program requires the iPhone Toolchain. You can view how to obtain and install it here.

Packaged Files

For your convenience this projects source code and compiled code is available for download in the following formats: tar.bz2, zip


Source Code

README

All files contained herein are under the copyright notice and license contained below. It is omitted from each individually displayed file for redundancy purposes only.

	empty - iPhone empty project with a blank window. 
	Copyright (C) 2007 David Supuran <http://www.iphonegameover.com>

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.


empty.h

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <UIKit/UIApplication.h>

@interface empty : UIApplication {

}

- (void) applicationDidFinishLaunching: (id) unused;

@end


empty.m

#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIWindow.h>
#import <UIKit/UIView-Hierarchy.h>
#import <UIKit/UIHardware.h>
#import "empty.h"

@implementation empty


- (void) applicationDidFinishLaunching: (id) unused
{
	struct CGRect rect	= [UIHardware fullScreenApplicationContentRect];

	rect.origin.x		= rect.origin.y = 0;

	/* Initialize the main window */
	UIWindow* window	= [[UIWindow alloc] initWithContentRect: rect];
	[window orderFront: self];
	[window makeKey: self];
	[window _setHidden: false];

	/* Initialize the main view */
	UIView* mainView	= [[[UIView alloc] initWithFrame: rect] autorelease];
	[window setContentView: mainView]; 

}

@end


main.m

#import <UIKit/UIKit.h>

#import "empty.h"

int main(int argc, char **argv)
{
	int ret;

	NSAutoreleasePool *pool	= [[NSAutoreleasePool alloc] init];

	ret	= UIApplicationMain(argc, argv, [empty class]);

	[pool release];

	return ret;
}


Makefile

NAME	:= empty
VERSION	:= 0.1

CC	:= arm-apple-darwin-gcc
CFLAGS	:= -Wall -pipe -ansi -O3
LD	:= ${CC}
LDFLAGS	:= -lobjc -framework CoreFoundation -framework Foundation -framework UIKit -framework LayerKit

all:	${NAME}

empty:	main.o ${NAME}.o
	$(LD) $(LDFLAGS) -o $@ $^

%.o:	%.m
	$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

clean:
	rm -f *.o ${NAME}
Personal tools