Graphics Programs Reference
In-Depth Information
Creating the TouchTracker Application
Now let's get started with your application. In Xcode , create a new Empty Application
iPhone project and name it TouchTracker . Don't specify a Class Prefix and only check the
box for Automatic Reference Counting .
First, you will need a model object that describes a line. Create a new NSObject and
name it Line . In Line.h , declare two CGPoint properties:
#import <Foundation/Foundation.h>
@interface Line : NSObject
@property (nonatomic) CGPoint begin;
@property (nonatomic) CGPoint end;
@end
In Line.m , synthesize the properties:
#import "Line.h"
@implementation Line
@synthesize begin, end;
@end
Next, create a new NSObject called TouchDrawView . In TouchDrawView.h ,
change the superclass to UIView . Also, declare two collection objects: an array to hold
complete lines and a dictionary to hold lines that are still being drawn. You'll see why
we're using different collection objects shortly.
#import <Foundation/Foundation.h>
@interface TouchDrawView : NSObject
@interface TouchDrawView : UIView
{
NSMutableDictionary *linesInProcess;
NSMutableArray *completeLines;
}
- (void)clearAll;
@end
Now you need a view controller to manage an instance of TouchDrawView in
TouchTracker . Create a new NSObject subclass named TouchViewController . In
TouchViewController.h , change the superclass to UIViewController .
@interface TouchViewController : NSObject
@interface TouchViewController : UIViewController
 
Search WWH ::




Custom Search