Functions

The following functions are available globally.

  • Returns YES if the object is empty, otherwise NO.

    This first tests the object against nil, then against NSNull.null, then checks if the object responds to count or length invokes the method and checks its return value.

    Declaration

    Objective-C

    extern BOOL KSTIsEmptyObject(id _Nullable object)

    Parameters

    object

    The object to test for emptiness

    Return Value

    YES if the object is empty, otherwise NO

  • Returns NSNull.null if the object is empty, using KSTIsEmptyObject to test, otherwise returns object.

    Declaration

    Objective-C

    extern id _Nonnull KSTNullIfEmptyOrObject(id _Nullable object)

    Parameters

    object

    The object to test

    Return Value

    NSNull.null or the object

  • Returns nil if the object is empty, using KSTIsEmptyObject to test, otherwise returns object.

    Declaration

    Objective-C

    extern id _Nullable KSTNilIfEmptyOrObject(id _Nullable object)

    Parameters

    object

    The object to test

    Return Value

    nil or the object

  • Executes block on the main thread asynchronously, using dispatch_async, passing dispatch_get_main_queue() and block respectively.

    Declaration

    Objective-C

    extern void KSTDispatchMainAsync(dispatch_block_t _Nonnull block)

    Parameters

    block

    The block to execute on the main thread @exception NSException Thrown if block is NULL

  • Executes block on the main thread synchronously, first checking to see if already on the main thread and if so, executing the block immediately. Otherwise using dispatch_sync, passing dispatch_get_main_queue() and block respectively.

    Declaration

    Objective-C

    extern void KSTDispatchMainSync(dispatch_block_t _Nonnull block)

    Parameters

    block

    The block to execute on the main thread @exception NSException Thrown if block is NULL

  • Executes block on the main thread after the provided delay.

    Declaration

    Objective-C

    extern void KSTDispatchMainAfter(NSTimeInterval delay,
                                     dispatch_block_t _Nonnull block)

    Parameters

    delay

    The delay after which to execute block

    block

    The block to execute @exception NSException Thrown if block is NULL

  • Executes block on the provided queue after the provided delay.

    Declaration

    Objective-C

    extern void KSTDispatchAfter(NSTimeInterval delay,
                                 dispatch_queue_t _Nullable queue,
                                 dispatch_block_t _Nonnull block)

    Parameters

    delay

    The delay after which to execute block

    queue

    The queue to execute block on

    block

    The block to execute @exception NSException Thrown if block is NULL

  • Returns a new CGSize by rounding both the width and height of the original using the ceil function.

    For example, KSTCGSizeIntegral(CGSizeMake(1.5, 2.1)) would return CGSizeMake(2, 3).

    Declaration

    Objective-C

    extern CGSize KSTCGSizeIntegral(CGSize size)

    Parameters

    size

    The size to round using ceil

    Return Value

    The new size

  • Creates and returns a CGRect by centering rect_to_center within in_rect.

    Declaration

    Objective-C

    extern CGRect KSTCGRectCenterInRect(CGRect rect_to_center, CGRect in_rect)

    Parameters

    rect_to_center

    The rectangle to center

    in_rect

    The bounding rectangle

    Return Value

    The centered rect

  • Calls KSTCGRectCenterInRect() and restores the resulting rectangle origin.y to its original value. This centers the rectangle horizontally.

    Declaration

    Objective-C

    extern CGRect KSTCGRectCenterInRectHorizontally(CGRect rect_to_center,
                                                    CGRect in_rect)

    Parameters

    rect_to_center

    The rectangle to center

    in_rect

    The bounding rectangle

    Return Value

    The centered rectangle

  • Calls KSTCGRectCenterInRect() and restores the resulting rectangle origin.x to its original value. This centers the rectangle vertically.

    Declaration

    Objective-C

    extern CGRect KSTCGRectCenterInRectVertically(CGRect rect_to_center,
                                                  CGRect in_rect)

    Parameters

    rect_to_center

    The rectangle to center

    in_rect

    The bounding rectangle

    Return Value

    The centered rectangle

  • Undocumented

    Declaration

    Objective-C

    static inline void kst_executeCleanupBlock (__strong kst_cleanupBlock_t *block) {
        (*block)();
    }