TCGBUtil Class Reference

Inherits from NSObject
Declared in TCGBUtil.h

Overview

The TCGBUtil class provides convenient and useful methods.

Utilities

+ appVersion

Gamebase Config Information

+ (NSString *)appVersion

Return Value

Gamebase Config Information

Declared In

TCGBUtil.h

+ gamebaseVersion

Gamebase Version

+ (NSString *)gamebaseVersion

Return Value

Gamebase Version

Declared In

TCGBUtil.h

+ appTrackingAuthorizationStatus

App Tracking AuthorizationStatus

+ (TCGBAppTrackingAuthorizationStatus)appTrackingAuthorizationStatus

Return Value

App Tracking AuthorizationStatus

Declared In

TCGBUtil.h

+ idfa

IDFA, Advertising Identifier.

+ (NSString *)idfa

Return Value

IDFA, Advertising Identifier.

Declared In

TCGBUtil.h

+ idfv

IDFV, Vendor Identifier.

+ (NSString *)idfv

Return Value

IDFV, Vendor Identifier.

Declared In

TCGBUtil.h

+ uuid

UUID, 4 random bytes string.

+ (NSString *)uuid

Return Value

UUID, 4 random bytes string.

Declared In

TCGBUtil.h

+ osCode

OS Code, actually “IOS”.

+ (NSString *)osCode

Return Value

OS Code, actually “IOS”.

Declared In

TCGBUtil.h

+ osVersion

OS Version.

+ (NSString *)osVersion

Return Value

OS Version.

Declared In

TCGBUtil.h

+ osVersionSeperatedByDot

OS Version dot-formatted.

+ (NSArray<NSString*> *)osVersionSeperatedByDot

Return Value

OS Version dot-formatted.

Declared In

TCGBUtil.h

+ isiOSVersion:orLater:

YES if majorVersion is greater than or equal to majorVersion.

+ (BOOL)isiOSVersion:(int)majorVersion orLater:(BOOL)later

Parameters

majorVersion

version to be compared with OS version.

later

if this value sets YES, it returns whether OS version is greater than or equal to majorVersion.

Return Value

YES if majorVersion is greater than or equal to majorVersion.

Declared In

TCGBUtil.h

+ deviceModel

Device model.

+ (NSString *)deviceModel

Return Value

Device model.

Declared In

TCGBUtil.h

+ detailDeviceModel

Detail Device model.

+ (NSString *)detailDeviceModel

Return Value

Detail Device model.

Declared In

TCGBUtil.h

+ deviceLanguageCode

Preferred launguage.

+ (NSString *)deviceLanguageCode

Return Value

Preferred launguage.

Availability

Added 1.14.0.

Declared In

TCGBUtil.h

+ deviceLocaleLanguageCode

language code by NSLocaleLanguageCode of NSLocale. (ex. “en”, “ko”, “ja”, “zh”, “vi”)

+ (NSString *)deviceLocaleLanguageCode

Return Value

language code by NSLocaleLanguageCode of NSLocale. (ex. “en”, “ko”, “ja”, “zh”, “vi”)

Declared In

TCGBUtil.h

+ deviceCountryCode

Locale country code is returned.

+ (NSString *)deviceCountryCode

Return Value

Locale country code is returned.

Declared In

TCGBUtil.h

+ bundleID

Main bundle’s identifier.

+ (NSString *)bundleID

Return Value

Main bundle’s identifier.

Declared In

TCGBUtil.h

+ displayName

DisplayName.

+ (NSString *)displayName

Return Value

DisplayName.

Declared In

TCGBUtil.h

+ unixEpochTime

Unix epoch time, it is millisecods, 13 digits.

+ (uint64_t)unixEpochTime

Return Value

Unix epoch time, it is millisecods, 13 digits.

Declared In

TCGBUtil.h

+ extractValueFrom:searchString:

value object which is in the json formatted dictionary and have a dottedString key.

+ (id)extractValueFrom:(NSDictionary *)json searchString:(NSString *)dottedString

Return Value

value object which is in the json formatted dictionary and have a dottedString key.

## Example
NSDictionary json;
json = @{
    @"key1" : @"value1",
    @"key2" : @{
        @"key2-1" : @"value2-1",
        @"key2-2" : @[@"value2-2[0]", @"value2-2[1]"]
    },
    @"key3" : @"value3"
}

NSString *dottedString = @"key2.key2-2[1]";
NSString *extractedString = [TCGBUtil extractValueFrom:json searchString:dottedString];
NSLog(@"%@", extractedString);
// It would be > "value2-2[1]"

Declared In

TCGBUtil.h

+ dictionaryFrom:

Returns an object converted from json string to dictionary.

+ (nullable NSDictionary *)dictionaryFrom:(NSString *)jsonString

Return Value

Returns an object converted from json string to dictionary.

Declared In

TCGBUtil.h

Encoding

+ isURLEncoded:

YES if the targetString is URL encoded.

+ (BOOL)isURLEncoded:(NSString *)targetString

Return Value

YES if the targetString is URL encoded.

Declared In

TCGBUtil.h

+ URLEncodedString:

URL Encoded String.

+ (nullable NSString *)URLEncodedString:(NSString *)string

Parameters

string

The string to be encoded.

Return Value

URL Encoded String.

Declared In

TCGBUtil.h

+ URLEncodedStringWithData:

URL Encoded String.

+ (nullable NSString *)URLEncodedStringWithData:(NSData *)data

Parameters

data

The data to be encoded.

Return Value

URL Encoded String.

Declared In

TCGBUtil.h

System UI

+ showToastWithMessage:length:

Show Toast.

+ (void)showToastWithMessage:(NSString *)message length:(GamebaseToastLength)length

Parameters

message

The message to be shown in the toast.

length

The time interval to be exposed. GamebaseToastLengthLong (3.5 seconds), GamebaseToastLengthShort (2 seconds)

Declared In

TCGBUtil.h

+ showAlertWithViewController:title:message:completion:

Show Alert View with async completion handler

+ (void)showAlertWithViewController:(UIViewController *)viewController title:(nullable NSString *)title message:(nullable NSString *)message completion:(void ( ^ _Nullable ) ( void ))completion

Parameters

viewController

The viewController that will display the alert

title

The title of alert

message

The message of alert

completion

The callback of alert when user has tapped the ‘OK(확인)’ button

Declared In

TCGBUtil.h

+ showAlertWithTitle:message:completion:

Show Alert View with async completion handler

+ (void)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message completion:(void ( ^ _Nullable ) ( void ))completion

Parameters

title

The title of alert

message

The message of alert

completion

The callback of alert when user has tapped the ‘OK(확인)’ button

Declared In

TCGBUtil.h

+ showAlertWithTitle:message:

Show Alert View

+ (void)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message

Parameters

title

The title of alert

message

The message of alert

Declared In

TCGBUtil.h

Logging

+ logVerboseWithFormat:

Verbose Log

+ (void)logVerboseWithFormat:(NSString *)format, ...

Parameters

format

Log

Declared In

TCGBUtil.h

+ logDebugWithFormat:

Debug Log

+ (void)logDebugWithFormat:(NSString *)format, ...

Parameters

format

Log

Declared In

TCGBUtil.h

+ logInfoWithFormat:

Info Log

+ (void)logInfoWithFormat:(NSString *)format, ...

Parameters

format

Log

Declared In

TCGBUtil.h

+ logWarnWithFormat:

Warning Log

+ (void)logWarnWithFormat:(NSString *)format, ...

Parameters

format

Log

Declared In

TCGBUtil.h

+ logErrorWithFormat:

Error Log

+ (void)logErrorWithFormat:(NSString *)format, ...

Parameters

format

Log

Declared In

TCGBUtil.h

+ logWithString:

Log

+ (void)logWithString:(NSString *)logString

Parameters

logString

Log

Declared In

TCGBUtil.h

+ osLog:

OS Log

+ (void)osLog:(NSString *)newString

Parameters

newString

Log

Declared In

TCGBUtil.h

Etc

+ colorFromHexString:

Convert color hex string to UIColor

+ (UIColor *)colorFromHexString:(NSString *)hexString

Parameters

hexString

The color hex string such as #RGB, #ARGB, #RRGGBB, #RRGGBBAA.

Return Value

UIColor.

Declared In

TCGBUtil.h

deprecated Methods

+ deviceLanguage

As of release 1.14.0, use deviceLanguageCode method instead. (Deprecated: As of release 1.14.0, use deviceLanguageCode method instead.)

+ (NSString *)deviceLanguage

Availability

Added 1.4.0.

Declared In

TCGBUtil.h

+ country

As of release 1.14.0, use countryCode method instead. (Deprecated: As of release 1.14.0, use countryCode method instead.)

+ (NSString *)country

Return Value

ISO country code. First, usimCountryCode is returned, if there is not usim, deviceCountryCode is returned.

Availability

Added 1.4.0.

Declared In

TCGBUtil.h

+ countryCode

As of release 2.52.0, use deviceCountryCode method instead. (Deprecated: As of release 2.52.0, use deviceCountryCode method instead.)

+ (NSString *)countryCode

Return Value

ISO country code. First, usimCountryCode is returned, if there is not usim, deviceCountryCode is returned.

Availability

Added 1.14.0.

Declared In

TCGBUtil.h

+ usimCountryCode

As of release 2.52.0, returns ‘ZZ’ since iOS 16.4. (Deprecated: As of release 2.52.0, returns ‘ZZ’ since iOS 16.4.)

+ (NSString *)usimCountryCode

Return Value

Usim country code is returned. If there is not usim, ‘ZZ’ is returned.

Availability

Added 1.4.0.

Declared In

TCGBUtil.h

+ carrierCode

As of release 2.52.0, returns nil since iOS 16.4. (Deprecated: As of release 2.52.0, returns nil since iOS 16.4.)

+ (NSString *)carrierCode

Return Value

Cellular service provider’s code.

Availability

Added 1.4.0.

Declared In

TCGBUtil.h

+ carrierName

As of release 2.52.0, returns nil since iOS 16.4. (Deprecated: As of release 2.52.0, returns nil since iOS 16.4.)

+ (NSString *)carrierName

Return Value

Cellular service provider’s name.

Availability

Added 1.4.0.

Declared In

TCGBUtil.h