NSString(ETStringTampering) Category Reference
Declared in | ETString.h |
Overview
NSString (ETStringTampering)
is a category that expands NSString
objects to provide formatting and validation specific methods.
Class Methods
formatCurrencyAmount:withLocale:
Formats a NSDecimalNumber
object to a currency formatted NSString
with the provided NSLocale
.
+ (NSString *)formatCurrencyAmount:(NSDecimalNumber *)value withLocale:(NSLocale *)locale
Parameters
- value
The
NSDecimalNumber
that will be currency formatted.
- locale
The
NSLocale
that will be used to format the provided amount as a currencyNSString
.
Return Value
The provided NSDecimalNumber
formatted as a currency NSString
using the provided NSLocale
.
Declared In
ETString.h
generateRandomStringWithLength:
Generate a NSString
object with random characters with the length provided.
+ (NSString *)generateRandomStringWithLength:(NSInteger)length
Parameters
- length
The lenght of the randomly generated
NSString
.
Return Value
A NSString
object composed of random characters with a length equal to the provided parameter.
Declared In
ETString.h
Instance Methods
containsNumbersOnly
Checks that every character on the NSString
instance is a number type character.
- (BOOL)containsNumbersOnly
Return Value
YES
if all the characters contained on the NSString
instance ara numbers NO
otherwise.
Declared In
ETString.h
containsString:
Checks if the NSString
instance contains the provided substring within itself.
- (BOOL)containsString:(NSString *)subString
Parameters
- subString
The
NSString
substring that needs to be contained in theNSString
instance.
Return Value
YES
if the provided subString is contained within the NSString
instance NO
otherwise.
Declared In
ETString.h
parseQueryStringArg:
Extracts the part after the ‘=’ in a typical HTTP query string.
- (NSString *)parseQueryStringArg:(NSString *)argName
Parameters
- argName
The name of the argument to look within the
URL
provided.
Return Value
The NSString
object associated to the arument provided (if any, nil
if none).
Discussion
NSString * url =
http://www.someURL.dot?someArgument=foobar&anotherArgument=blarfo
NSString * arg = [url parseQueryStringArg:@"someArgument"];
arg is ‘foobar’
Declared In
ETString.h