Sha256: dcb0692b7ba027facefc4eff6b17983b50520c9ac1a6fd7ad1ab47f8374dba06

Contents?: true

Size: 1.64 KB

Versions: 8

Compression:

Stored size: 1.64 KB

Contents

#import <UIKit/UIKit.h>

#import "Recorder.h"

@interface UIApplication (Recording)

-(void)_addRecorder:(id)recorder;
-(void)_removeRecorder:(id)recorder;
-(void)_playbackEvents:(NSArray*)events atPlaybackRate:(float)playbackRate messageWhenDone:(id)target withSelector:(SEL)selector;

@end

static Recorder *sharedRecorder = nil;

@implementation Recorder

+(Recorder *)sharedRecorder {
	if (sharedRecorder == nil) {
		sharedRecorder = [[super allocWithZone:NULL] init];
	}
	return sharedRecorder;
}

-(id)init {
	self = [super init];

	eventList = [[NSMutableArray alloc] init];

	return self;
}

-(void)dealloc {
	[eventList release];
	[super dealloc];
}

-(void)record {
	[eventList removeAllObjects];

	NSLog(@"Starting recording");

	[[UIApplication sharedApplication] _addRecorder: self];
}

-(void)saveToFile:(NSString*)path {
	NSLog(@"Saving events to file: %@", path);

	[eventList writeToFile: path atomically: YES];
}

-(void)stop {
	NSLog(@"Stopping recording");

	[[UIApplication sharedApplication] _removeRecorder: self];
}

-(void)recordApplicationEvent:(NSDictionary*)event {
	NSLog(@"Recorded event: %@", event);

	[eventList addObject:event];
}

-(void)load:(NSArray*)events {
	NSLog(@"Loading events");

	[eventList setArray: events];
}

-(void)loadFromFile:(NSString*)path {
	NSLog(@"Loading events from file: %@", path);

	[eventList setArray: [NSMutableArray arrayWithContentsOfFile: path]];
}

-(void)play {
	NSLog(@"Starting playback");

	[[UIApplication sharedApplication] _playbackEvents: eventList atPlaybackRate: 1.0f messageWhenDone: self withSelector: @selector(done:)];
}

-(void)done:(NSDictionary*)detail {
	NSLog(@"Finished playback");
}

@end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
iCuke-0.4.12 ext/iCuke/Recorder.m
iCuke-0.4.11 ext/iCuke/Recorder.m
iCuke-0.4.10 ext/iCuke/Recorder.m
iCuke-0.4.9 ext/iCuke/Recorder.m
iCuke-0.4.8 ext/iCuke/Recorder.m
iCuke-0.4.7 ext/iCuke/Recorder.m
iCuke-0.4.6 ext/iCuke/Recorder.m
iCuke-0.4.5 ext/iCuke/Recorder.m