TiUtils Class Reference
Inherits from | NSObject |
Declared in | TiUtils.h |
Tasks
-
+ UTCDateForDate:
Converts date to UTC format.
-
+ dateForUTCDate:
Converts string in UTC format into a date.
-
+ UTCDate
Returns current date in UTC format.
-
+ createUUID
Generates a new UUID.
-
+ createTempFile:
Creates a temporary file with name extension.
-
+ loadAppResource:
Loads application bundle resource by URL.
-
+ encodeQueryPart:
Encodes the input string according by escaping illegal characters.
-
+ encodeURIParameters:
Encodes the URL query string by escaping illegal characters.
-
+ toURL:relativeToURL:
Constructs URL from string using provided base URL.
-
+ toURL:proxy:
Constructs URL from string using proxy’s base URL.
-
+ image:proxy:
Loads and returns image for the provided object.
-
+ stringValue:
Converts input value into a string.
-
+ boolValue:
Converts input value into a boolean.
-
+ boolValue:def:
Converts input value into a boolean with default fallback.
-
+ pointValue:
Converts input value into a point type.
-
+ pointValue:valid:
Converts input value into the point type.
-
+ floatValue:
Converts input value into a float.
-
+ floatValue:def:
Converts input value into a float with default fallback.
-
+ floatValue:def:valid:
Converts input value into a float with default fallback.
-
+ doubleValue:
Converts input value into a double.
-
+ doubleValue:def:
Converts input value into a double with default fallback.
-
+ doubleValue:def:valid:
Converts input value into a double with default fallback.
-
+ intValue:
Converts input value into an int.
-
+ intValue:def:
Converts input value into an int with default fallback.
-
+ intValue:def:valid:
Converts input value into an int with default fallback.
-
+ colorValue:
Converts input value into the color type.
-
+ dimensionValue:
Converts input value into the dimention type.
-
+ intValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as an int.
-
+ doubleValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a double.
-
+ floatValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a float.
-
+ boolValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a boolean.
-
+ stringValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a string.
-
+ pointValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a point.
-
+ colorValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a color.
-
+ dimensionValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a dimension.
-
+ isOrientationPortait
Whether or not the current device orientation is portrait.
-
+ isOrientationLandscape
Whether or not the current device orientation is landscape.
-
+ orientation
Returns the current device orientation.
-
+ setView:positionRect:
Sets the view’s bounds and center coordinates.
-
+ isIPad
Whether or not the current device interface idiom is iPad.
-
+ isIOS4_2OrGreater
Whether or not the current OS version is equal to or greater than 4.2.
-
+ isIOS5OrGreater
Whether or not the current OS version is equal to or greater than 5.0.
-
+ isIOS6OrGreater
Whether or not the current OS version is equal to or greater than 6.0.
-
+ isIPhone4
Whether or not the current device is an iPhone 4.
-
+ isRetinaDisplay
Whether or not the current device has retina display.
-
+ isRetinaFourInch
Whether or not the current device has a 4 inch retina display (iPhone5).
-
+ md5:
Generates MD5 hash for the provided data.
-
+ convertToHex:length:
Converts array of byte into a hex string.
Class Methods
UTCDate
Returns current date in UTC format.
+ (NSString *)UTCDate
Return Value
The date string in UTC format.
Declared In
TiUtils.h
UTCDateForDate:
Converts date to UTC format.
+ (NSString *)UTCDateForDate:(NSDate *)date
Parameters
- date
The input date.
Return Value
The date string in UTC format.
Declared In
TiUtils.h
boolValue:
Converts input value into a boolean.
+ (BOOL)boolValue:(id)value
Parameters
- value
The input value.
Return Value
The boolean representation of the value.
See Also
Declared In
TiUtils.h
boolValue:def:
Converts input value into a boolean with default fallback.
+ (BOOL)boolValue:(id)value def:(BOOL)def
Parameters
- value
The input value.
- def
The default value if the input value cannot be converted.
Return Value
The boolean representation of the value or default value otherwise.
See Also
Declared In
TiUtils.h
boolValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a boolean.
+ (BOOL)boolValue:(NSString *)name properties:(NSDictionary *)properties def:(BOOL)def exists:(BOOL *)exists
Parameters
- name
The lookup key.
- properties
The dictionary.
- def
The default value if the key doesn’t exist in the dictionary.
- exists
The optional output parameter indicating the status of dictionary lookup. If not NULL, its value is set to YES if the key was founda and NO otherwise.
Return Value
The resulting value as a boolean
Declared In
TiUtils.h
colorValue:
Converts input value into the color type.
+ (TiColor *)colorValue:(id)value
Parameters
- value
The input value of either TiColor type or class with string representation that could be converted to a color.
Return Value
The color representation of the value or nil if the input value cannot be converted.
Declared In
TiUtils.h
colorValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a color.
+ (TiColor *)colorValue:(NSString *)name properties:(NSDictionary *)properties def:(TiColor *)def exists:(BOOL *)exists
Parameters
- name
The lookup key.
- properties
The dictionary.
- def
The default value if the key doesn’t exist in the dictionary.
- exists
The optional output parameter indicating the status of dictionary lookup. If not NULL, its value is set to YES if the key was founda and NO otherwise.
Return Value
The resulting value as a color
Declared In
TiUtils.h
convertToHex:length:
Converts array of byte into a hex string.
+ (NSString *)convertToHex:(unsigned char *)input length:(size_t)length
Parameters
- input
The array of bytes.
- length
The length of the input array.
Return Value
Hex representation of the input array.
Declared In
TiUtils.h
createTempFile:
Creates a temporary file with name extension.
+ (TiFile *)createTempFile:(NSString *)extension
Parameters
- extension
The filename extension.
Return Value
The created temporary file object.
Declared In
TiUtils.h
createUUID
Generates a new UUID.
+ (NSString *)createUUID
Return Value
The generate UUID.
Declared In
TiUtils.h
dateForUTCDate:
Converts string in UTC format into a date.
+ (NSDate *)dateForUTCDate:(NSString *)date
Parameters
- date
The date string in UTC format.
Return Value
The converted date.
Declared In
TiUtils.h
dimensionValue:
Converts input value into the dimention type.
+ (TiDimension)dimensionValue:(id)value
Parameters
- value
The input value that could be converted to a color.
Return Value
The dimension representation of the value or TiDimensionUndefined if the input value cannot be converted.
Declared In
TiUtils.h
dimensionValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a dimension.
+ (TiDimension)dimensionValue:(NSString *)name properties:(NSDictionary *)properties def:(TiDimension)def exists:(BOOL *)exists
Parameters
- name
The lookup key.
- properties
The dictionary.
- def
The default value if the key doesn’t exist in the dictionary.
- exists
The optional output parameter indicating the status of dictionary lookup. If not NULL, its value is set to YES if the key was founda and NO otherwise.
Return Value
The resulting value as a dimension
Declared In
TiUtils.h
doubleValue:
Converts input value into a double.
+ (double)doubleValue:(id)value
Parameters
- value
The input value.
Return Value
The double representation of the value.
See Also
Declared In
TiUtils.h
doubleValue:def:
Converts input value into a double with default fallback.
+ (double)doubleValue:(id)value def:(double)def
Parameters
- value
The input value.
- def
The default value if the input value cannot be converted.
Return Value
The double representation of the value.
See Also
Declared In
TiUtils.h
doubleValue:def:valid:
Converts input value into a double with default fallback.
+ (double)doubleValue:(id)value def:(double)def valid:(BOOL *)isValid
Parameters
- value
The input value.
- def
The default value if the input value cannot be converted.
- isValid
The optional output parameter indicating the status of the convertion. If not NULL, its value is set to YES if the value was converted successfully and NO otherwise.
Return Value
The double representation of the value.
See Also
Declared In
TiUtils.h
doubleValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a double.
+ (double)doubleValue:(NSString *)name properties:(NSDictionary *)properties def:(double)def exists:(BOOL *)exists
Parameters
- name
The lookup key.
- properties
The dictionary.
- def
The default value if the key doesn’t exist in the dictionary.
- exists
The optional output parameter indicating the status of dictionary lookup. If not NULL, its value is set to YES if the key was founda and NO otherwise.
Return Value
The resulting value as a double
Declared In
TiUtils.h
encodeQueryPart:
Encodes the input string according by escaping illegal characters.
+ (NSString *)encodeQueryPart:(NSString *)unencodedString
Parameters
- unencodedString
The input string.
Return Value
The encoded string.
Declared In
TiUtils.h
encodeURIParameters:
Encodes the URL query string by escaping illegal characters.
+ (NSString *)encodeURIParameters:(NSString *)unencodedString
Parameters
- unencodedString
The input string.
Return Value
The encoded string.
Declared In
TiUtils.h
floatValue:
Converts input value into a float.
+ (CGFloat)floatValue:(id)value
Parameters
- value
The input value.
Return Value
The float representation of the value.
See Also
Declared In
TiUtils.h
floatValue:def:
Converts input value into a float with default fallback.
+ (CGFloat)floatValue:(id)value def:(CGFloat)def
Parameters
- value
The input value.
- def
The default value if the input value cannot be converted.
Return Value
The float representation of the value.
See Also
Declared In
TiUtils.h
floatValue:def:valid:
Converts input value into a float with default fallback.
+ (CGFloat)floatValue:(id)value def:(CGFloat)def valid:(BOOL *)isValid
Parameters
- value
The input value.
- def
The default value if the input value cannot be converted.
- isValid
The optional output parameter indicating the status of the convertion. If not NULL, its value is set to YES if the value was converted successfully and NO otherwise.
Return Value
The float representation of the value.
See Also
Declared In
TiUtils.h
floatValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a float.
+ (float)floatValue:(NSString *)name properties:(NSDictionary *)properties def:(float)def exists:(BOOL *)exists
Parameters
- name
The lookup key.
- properties
The dictionary.
- def
The default value if the key doesn’t exist in the dictionary.
- exists
The optional output parameter indicating the status of dictionary lookup. If not NULL, its value is set to YES if the key was founda and NO otherwise.
Return Value
The resulting value as a float
Declared In
TiUtils.h
image:proxy:
Loads and returns image for the provided object.
+ (UIImage *)image:(id)object proxy:(TiProxy *)proxy
Parameters
- object
The input object. It could be either TiBlob or NSString.
- proxy
The proxy to use as base URL for image loading if object type is NSString.
Return Value
The loaded image.
Discussion
If the object parameter type is TiBlob, it will be converted to image and returned. Otherwise if the object type is NSString, it will be first converted to URL using proxy as a base, then the image will be loaded from the URL.
See Also
Declared In
TiUtils.h
intValue:
Converts input value into an int.
+ (int)intValue:(id)value
Parameters
- value
The input value.
Return Value
The int representation of the value.
See Also
Declared In
TiUtils.h
intValue:def:
Converts input value into an int with default fallback.
+ (int)intValue:(id)value def:(int)def
Parameters
- value
The input value.
- def
The default value if the input value cannot be converted.
Return Value
The int representation of the value.
See Also
Declared In
TiUtils.h
intValue:def:valid:
Converts input value into an int with default fallback.
+ (int)intValue:(id)value def:(int)def valid:(BOOL *)isValid
Parameters
- value
The input value.
- def
The default value if the input value cannot be converted.
- isValid
The optional output parameter indicating the status of the convertion. If not NULL, its value is set to YES if the value was converted successfully and NO otherwise.
Return Value
The int representation of the value.
See Also
Declared In
TiUtils.h
intValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as an int.
+ (int)intValue:(NSString *)name properties:(NSDictionary *)properties def:(int)def exists:(BOOL *)exists
Parameters
- name
The lookup key.
- properties
The dictionary.
- def
The default value if the key doesn’t exist in the dictionary.
- exists
The optional output parameter indicating the status of dictionary lookup. If not NULL, its value is set to YES if the key was founda and NO otherwise.
Return Value
The resulting value as an int
Declared In
TiUtils.h
isIOS4_2OrGreater
Whether or not the current OS version is equal to or greater than 4.2.
+ (BOOL)isIOS4_2OrGreater
Return Value
YES if the current OS version is equal to or greater than 4.2, NO otherwise.
Declared In
TiUtils.h
isIOS5OrGreater
Whether or not the current OS version is equal to or greater than 5.0.
+ (BOOL)isIOS5OrGreater
Return Value
YES if the current OS version is equal to or greater thann 5.0, NO otherwise.
Declared In
TiUtils.h
isIOS6OrGreater
Whether or not the current OS version is equal to or greater than 6.0.
+ (BOOL)isIOS6OrGreater
Return Value
YES if the current OS version is equal to or greater thann 6.0, NO otherwise.
Declared In
TiUtils.h
isIPad
Whether or not the current device interface idiom is iPad.
+ (BOOL)isIPad
Return Value
YES if the current device interface idiom is iPad, NO otherwise.
Declared In
TiUtils.h
isIPhone4
Whether or not the current device is an iPhone 4.
+ (BOOL)isIPhone4
Return Value
YES if the current device is an iPhone 4, NO otherwise.
Declared In
TiUtils.h
isOrientationLandscape
Whether or not the current device orientation is landscape.
+ (BOOL)isOrientationLandscape
Return Value
YES is the current device orientation is landscape, NO otherwise.
Declared In
TiUtils.h
isOrientationPortait
Whether or not the current device orientation is portrait.
+ (BOOL)isOrientationPortait
Return Value
YES is the current device orientation is portrait, NO otherwise.
Declared In
TiUtils.h
isRetinaDisplay
Whether or not the current device has retina display.
+ (BOOL)isRetinaDisplay
Return Value
YES if the current device has retina display, NO otherwise.
Declared In
TiUtils.h
isRetinaFourInch
Whether or not the current device has a 4 inch retina display (iPhone5).
+ (BOOL)isRetinaFourInch
Return Value
YES if the current device has a 4 inch retina display, NO otherwise.
Declared In
TiUtils.h
loadAppResource:
Loads application bundle resource by URL.
+ (NSData *)loadAppResource:(NSURL *)url
Parameters
- url
The resource URL
Return Value
The resource data.
Declared In
TiUtils.h
md5:
Generates MD5 hash for the provided data.
+ (NSString *)md5:(NSData *)data
Parameters
- data
The input data.
Return Value
MD5 hash string.
Declared In
TiUtils.h
orientation
Returns the current device orientation.
+ (UIInterfaceOrientation)orientation
Return Value
The current device orientation.
Declared In
TiUtils.h
pointValue:
Converts input value into a point type.
+ (CGPoint)pointValue:(id)value
Parameters
- value
The input value of either TiPoint type or NSDictionary with {x,y} keys.
Return Value
The point representation of the value or {0,0} if the input value cannot be converted.
See Also
Declared In
TiUtils.h
pointValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a point.
+ (CGPoint)pointValue:(NSString *)name properties:(NSDictionary *)properties def:(CGPoint)def exists:(BOOL *)exists
Parameters
- name
The lookup key.
- properties
The dictionary.
- def
The default value if the key doesn’t exist in the dictionary.
- exists
The optional output parameter indicating the status of dictionary lookup. If not NULL, its value is set to YES if the key was founda and NO otherwise.
Return Value
The resulting value as a point
Declared In
TiUtils.h
pointValue:valid:
Converts input value into the point type.
+ (CGPoint)pointValue:(id)value valid:(BOOL *)isValid
Parameters
- value
The input value of either TiPoint type or NSDictionary with {x,y} keys.
- isValid
The optional output parameter indicating the status of the convertion. If not NULL, its value is set to YES if the value was converted successfully and NO otherwise.
Return Value
The point representation of the value or {0,0} if the input value cannot be converted.
See Also
Declared In
TiUtils.h
setView:positionRect:
Sets the view’s bounds and center coordinates.
+ (void)setView:(UIView *)view positionRect:(CGRect)frameRect
Parameters
- view
The view to make changes on.
- frameRect
The rectangle containing bounds to apply to the view.
Declared In
TiUtils.h
stringValue:
Converts input value into a string.
+ (NSString *)stringValue:(id)value
Parameters
- value
The input value.
Return Value
The textual representation of the value.
Declared In
TiUtils.h
stringValue:properties:def:exists:
Looks up a value for the key in the provided dictionary and returns it as a string.
+ (NSString *)stringValue:(NSString *)name properties:(NSDictionary *)properties def:(NSString *)def exists:(BOOL *)exists
Parameters
- name
The lookup key.
- properties
The dictionary.
- def
The default value if the key doesn’t exist in the dictionary.
- exists
The optional output parameter indicating the status of dictionary lookup. If not NULL, its value is set to YES if the key was founda and NO otherwise.
Return Value
The resulting value as a string
Declared In
TiUtils.h