Declared in NSString+BFKit.h

Overview

This category adds some useful methods to NSString

Tasks

Class Methods

convertToNSData:

+ (NSData *_Nonnull)convertToNSData:(NSString *_Nonnull)string
Discussion

Convert the given NSString to NSData

Parameters

string

The NSString to be converted

Return Value

Returns the converted NSString as NSData

Declared In

NSString+BFKit.h

convertToUTF8Entities:

+ (NSString *_Nonnull)convertToUTF8Entities:(NSString *_Nonnull)string
Discussion

Convert a string to UTF8

Parameters

string

String to be converted

Return Value

Returns the converted string

Declared In

NSString+BFKit.h

decodeBase64:

+ (NSString *_Nonnull)decodeBase64:(NSString *_Nonnull)string
Discussion

Decode the given Base64 to string

Parameters

string

String to decode

Return Value

Returns the decoded string

Declared In

NSString+BFKit.h

encodeToBase64:

+ (NSString *_Nonnull)encodeToBase64:(NSString *_Nonnull)string
Discussion

Encode the given string to Base64

Parameters

string

String to encode

Return Value

Returns the encoded string

Declared In

NSString+BFKit.h

generateUUID

+ (NSString *_Nonnull)generateUUID
Discussion

Used to create an UUID as NSString

Return Value

Returns the created UUID string

Declared In

NSString+BFKit.h

isEmail:

+ (BOOL)isEmail:(NSString *_Nonnull)email
Discussion

Check if the given string is an email

Parameters

email

The string to be checked

Return Value

Returns YES if it’s an email, NO if not

Declared In

NSString+BFKit.h

searchInString:charStart:charEnd:

+ (NSString *_Nonnull)searchInString:(NSString *_Nonnull)string charStart:(char)start charEnd:(char)end
Discussion

Search in a given string a substring from the start char to the end char (excluded form final string). Example: “This is a test” with start char ‘h’ and end char ’t' will return “is is a ”

Parameters

string

The string to search in

start

The start char

end

The end char

Return Value

Returns the substring

Declared In

NSString+BFKit.h

Instance Methods

HEXToString

- (NSString *_Nonnull)HEXToString
Discussion

Convert HEX string (separated by space) to “usual” characters string. Example: “68 65 6c 6c 6f” -> “hello”

Return Value

Readable string

Declared In

NSString+BFKit.h

MD5

- (NSString *_Nullable)MD5
Discussion

Create a MD5 string from self

Return Value

Returns the MD5 NSString from self

Declared In

NSString+BFKit.h

SHA1

- (NSString *_Nullable)SHA1
Discussion

Create a SHA1 string from self

Return Value

Returns the SHA1 NSString from self

Declared In

NSString+BFKit.h

SHA256

- (NSString *_Nullable)SHA256
Discussion

Create a SHA256 string from self

Return Value

Returns the SHA256 NSString from self

Declared In

NSString+BFKit.h

SHA512

- (NSString *_Nullable)SHA512
Discussion

Create a SHA512 string from self

Return Value

Returns the SHA512 NSString from self

Declared In

NSString+BFKit.h

URLEncode

- (NSString *_Nonnull)URLEncode
Discussion

Encode self to an encoded url string

Return Value

Returns the encoded NSString

Declared In

NSString+BFKit.h

convertToAPNSUUID

- (NSString *_Nonnull)convertToAPNSUUID
Discussion

Converts self to an UUID APNS valid (No “<>” or “-” or spaces)

Return Value

Converts self to an UUID APNS valid (No “<>” or “-” or spaces)

Declared In

NSString+BFKit.h

convertToNSData

- (NSData *_Nonnull)convertToNSData
Discussion

Convert self to a NSData

Return Value

Returns self as NSData

Declared In

NSString+BFKit.h

dateFromTimestamp

- (NSString *_Nonnull)dateFromTimestamp
Discussion

Returns a human legible string from a timestamp

Return Value

Returns a human legible string from a timestamp

Declared In

NSString+BFKit.h

decodeBase64

- (NSString *_Nonnull)decodeBase64
Discussion

Decode the given Base64 to string

Return Value

Returns the decoded string

Declared In

NSString+BFKit.h

encodeToBase64

- (NSString *_Nonnull)encodeToBase64
Discussion

Encode the given string to Base64

Return Value

Returns the encoded string

Declared In

NSString+BFKit.h

hasString:

- (BOOL)hasString:(NSString *_Nonnull)substring
Discussion

Check if self has the given substring in case-sensitive

Parameters

substring

The substring to be searched

Return Value

Returns YES if founded, NO if not

Declared In

NSString+BFKit.h

hasString:caseSensitive:

- (BOOL)hasString:(NSString *_Nonnull)substring caseSensitive:(BOOL)caseSensitive
Discussion

Check if self has the given substring specifying if is case-sensitive or not

Parameters

substring

The substring to be searched

caseSensitive

If the search has to be case-sensitive or not

Return Value

Returns YES if founded, NO if not

Declared In

NSString+BFKit.h

heightForWidth:andFont:

- (CGFloat)heightForWidth:(float)width andFont:(UIFont *_Nonnull)font
Discussion

Used to calculate text height for max width and font

Parameters

width

Max width to fit text

font

Font used in text

Return Value

Returns the calculated height of string within width using given font

Declared In

NSString+BFKit.h

indexOfCharacter:

- (NSInteger)indexOfCharacter:(char)character
Discussion

Returns the index of the given character

Parameters

character

The character to search

Return Value

Returns the index of the given character, -1 if not found

Declared In

NSString+BFKit.h

isEmail

- (BOOL)isEmail
Discussion

Check if self is an email

Return Value

Returns YES if it’s an email, NO if not

Declared In

NSString+BFKit.h

isUUID

- (BOOL)isUUID
Discussion

Returns if self is a valid UUID or not

Return Value

Returns if self is a valid UUID or not

Declared In

NSString+BFKit.h

isUUIDForAPNS

- (BOOL)isUUIDForAPNS
Discussion

Returns if self is a valid UUID for APNS (Apple Push Notification System) or not

Return Value

Returns if self is a valid UUID for APNS (Apple Push Notification System) or not

Declared In

NSString+BFKit.h

removeExtraSpaces

- (NSString *_Nonnull)removeExtraSpaces
Discussion

Remove double or more duplicated spaces

Return Value

String without additional spaces

Declared In

NSString+BFKit.h

searchCharStart:charEnd:

- (NSString *_Nonnull)searchCharStart:(char)start charEnd:(char)end
Discussion

Search in a given string a substring from the start char to the end char (excluded form final string). Example: “This is a test” with start char ‘h’ and end char ’t' will return “is is a ”

Parameters

start

The start char

end

The end char

Return Value

Returns the substring

Declared In

NSString+BFKit.h

sentenceCapitalizedString

- (NSString *_Nonnull)sentenceCapitalizedString
Discussion

Conver self to a capitalized string. Example: “This is a Test” will return “This is a test” and “this is a test” will return “This is a test”

Return Value

Returns the capitalized sentence string

Declared In

NSString+BFKit.h

stringByReplacingWithRegex:withString:

- (NSString *_Nonnull)stringByReplacingWithRegex:(NSString *_Nonnull)regexString withString:(NSString *_Nonnull)replacement
Discussion

Returns a new string containing matching regular expressions replaced with the template string

Parameters

regexString

The regex string

replacement

The replacement string

Return Value

Returns a new string containing matching regular expressions replaced with the template string

Declared In

NSString+BFKit.h

stringToHEX

- (NSString *_Nonnull)stringToHEX
Discussion

Convert string to HEX string. Example: “hello” -> “68656c6c6f”

Return Value

HEX string

Declared In

NSString+BFKit.h

substringFromCharacter:

- (NSString *_Nonnull)substringFromCharacter:(char)character
Discussion

Creates a substring from the given character

Parameters

character

The character

Return Value

Returns the substring from character

Declared In

NSString+BFKit.h

substringToCharacter:

- (NSString *_Nonnull)substringToCharacter:(char)character
Discussion

Creates a substring to the given character

Parameters

character

The character

Return Value

Returns the substring to character

Declared In

NSString+BFKit.h

urlEncode

- (NSString *_Nonnull)urlEncode
Discussion

Encode self to an encoded url string

Return Value

Returns the encoded NSString

Declared In

NSString+BFKit.h