Inherits from NSObject
Declared in SLDevice.h

Overview

The singleton SLDevice instance allows you to access and manipulate the device on which your application is running.

Tasks

Getting the Shared Instance

Interacting with Hardware Buttons

Device Orientation

Screenshots

Class Methods

currentDevice

Returns an object representing the current device.

+ (SLDevice *)currentDevice

Return Value

A singleton object that represents the current device.

Declared In

SLDevice.h

Instance Methods

captureScreenshotWithFilename:

Takes a screenshot of the entire device screen.

- (void)captureScreenshotWithFilename:(NSString *)filename

Parameters

filename

A string to use as the name for the resultant image file.

Discussion

The image is viewable from the UIAutomation debug log in Instruments.

When running subliminal-test from the command line, the images are also saved as PNGs within the specified output directory.

Declared In

SLDevice.h

captureScreenshotWithFilename:inRect:

Takes a screenshot of the specified rectangular portion of the device screen.

- (void)captureScreenshotWithFilename:(NSString *)filename inRect:(CGRect)rect

Parameters

filename

A string to use as the name for the resultant image file.

rect

The rect that defines the area of the screen to capture.

Discussion

The image is viewable from the UIAutomation debug log in Instruments.

When running subliminal-test from the command line, the images are also saved as PNGs within the specified output directory.

Exceptions

NSInternalInconsistencyException

if rect is CGRectNull.

Declared In

SLDevice.h

deactivateAppForDuration:

Deactivates your application for the specified duration.

- (void)deactivateAppForDuration:(NSTimeInterval)duration

Parameters

duration

The time, in seconds, for the app to remain inactive (subject to the caveat in the discussion).

Discussion

By pushing the Home button, waiting for the specified duration, and then using the app switcher to reactivate the application.

This method will not return until the app reactivates.

Note that the time spent inactive will actually be a few seconds longer than specified; UIAutomation lingers upon the app switcher for several seconds before actually tapping the app.

Declared In

SLDevice.h

setOrientation:

Changes the device orientation to the specified new deviceOrientation value.

- (void)setOrientation:(UIDeviceOrientation)deviceOrientation

Parameters

deviceOrientation

The device orientation to rotate to.

Discussion

You can access the current device orientation using [[UIDevice currentDevice] orientation].

Declared In

SLDevice.h