Inherits from NSObject
Declared in SPUtils.h

Overview

The SPUtils class contains utility methods for different purposes.

Tasks

  • + nextPowerOfTwo:

    Finds the next power of two equal to or above the specified number.

  • + randomIntBetweenMin:andMax:

    Returns a random integer number between minValue (inclusive) and maxValue (exclusive).

  • + randomFloat

    Returns a random float number between 0.0 and 1.0

  • + fileExistsAtPath:

    Returns a Boolean value that indicates whether a file or directory exists at a specified path.

  • + absolutePathToFile:withScaleFactor:idiom:

    Finds the full path for a file with a certain scale factor (a file with a suffix like ‘@2x’) and user interface idiom (‘~ipad’ or ‘~iphone’). Relative paths are searched in the application bundle.

  • + absolutePathToFile:withScaleFactor:

    Finds the full path for a file with a certain scale factor (a file with a suffix like ‘@2x’), adhering the current user interface idiom. Relative paths are searched in the application bundle.

  • + absolutePathToFile:

    Returns the absolute path to a file, or nil if it does not exist.

Class Methods

absolutePathToFile:

Returns the absolute path to a file, or nil if it does not exist.

+ (NSString *)absolutePathToFile:(NSString *)path

Discussion

Returns the absolute path to a file, or nil if it does not exist.

Declared In

SPUtils.h

absolutePathToFile:withScaleFactor:

Finds the full path for a file with a certain scale factor (a file with a suffix like ‘@2x’), adhering the current user interface idiom. Relative paths are searched in the application bundle.

+ (NSString *)absolutePathToFile:(NSString *)path withScaleFactor:(float)factor

Discussion

Finds the full path for a file with a certain scale factor (a file with a suffix like ‘@2x’), adhering the current user interface idiom. Relative paths are searched in the application bundle.

Declared In

SPUtils.h

absolutePathToFile:withScaleFactor:idiom:

Finds the full path for a file with a certain scale factor (a file with a suffix like ‘@2x’) and user interface idiom (‘~ipad’ or ‘~iphone’). Relative paths are searched in the application bundle.

+ (NSString *)absolutePathToFile:(NSString *)path withScaleFactor:(float)factor idiom:(UIUserInterfaceIdiom)idiom

Return Value

The path to the scaled resource with idiom suffix; if that does not exist, the path to the scaled resource without idiom suffix; if that does not exist either, the path to the unscaled resource (first with, then without idiom). If none of those exist, nil.

Discussion

Finds the full path for a file with a certain scale factor (a file with a suffix like ‘@2x’) and user interface idiom (‘~ipad’ or ‘~iphone’). Relative paths are searched in the application bundle.

Declared In

SPUtils.h

fileExistsAtPath:

Returns a Boolean value that indicates whether a file or directory exists at a specified path.

+ (BOOL)fileExistsAtPath:(NSString *)path

Discussion

Returns a Boolean value that indicates whether a file or directory exists at a specified path.

Declared In

SPUtils.h

nextPowerOfTwo:

Finds the next power of two equal to or above the specified number.

+ (int)nextPowerOfTwo:(int)number

Discussion

Finds the next power of two equal to or above the specified number.

Declared In

SPUtils.h

randomFloat

Returns a random float number between 0.0 and 1.0

+ (float)randomFloat

Discussion

Returns a random float number between 0.0 and 1.0

Declared In

SPUtils.h

randomIntBetweenMin:andMax:

Returns a random integer number between minValue (inclusive) and maxValue (exclusive).

+ (int)randomIntBetweenMin:(int)minValue andMax:(int)maxValue

Discussion

Returns a random integer number between minValue (inclusive) and maxValue (exclusive).

Declared In

SPUtils.h