Latest 0.0.4
Homepage https://github.com/belkevich/blocks
License MIT
Platforms ios 5.0, osx 10.7, tvos 9.0, requires ARC
Authors

Useful Macros for Objective-c

Macros for Blocks

Tired with block != nil check? Too many code lines to run block on dispatch queue? This macros for you!

Add pod 'macros_blocks' to Podfile

Call Block Safely

safe_block(block, arguments);

is equal to

if (block)
{
    block(arguments);
}

Call Block on Main Queue

main_queue_block(block, arguments);

is equal to

dispatch_async(dispatch_get_main_queue(), ^
{
    if (block)
    {
        block(arguments);
    }
});

Call Block on Custom Queue Asynchronously

async_queue_block(queue, block, arguments)

is equal to

dispatch_async(queue, ^
{
    if (block)
    {
        block(arguments);
    }
});

Extra Macros

Add pod 'macros_blocks/extra' to Podfile

Trim Value in Range
Value should be greater or equal then minimum and less or equal then maximum. Otherwise it will equal minimum if less or maximum if greater.

range_value(5, 1, 10);   // 1 < 5 < 10 => 5
range_value(0, 1, 10);   // 1 > 0 => 1
range_value(12, 1, 10);  // 10 < 12 => 12

Safe Malloc
Return NULL if malloc size is 0.

size_t x = 0;
safe_malloc(x);

All Macros

Install both ‘blocks’ and ‘extra’ macros.

Add pod 'macros_blocks/all' to Podfile

#import <macros_blocks/macros_all.h>

Updates

Follow updates on twitter @okolodev

Changelog

0.0.3

  • Improved autocomplete for value in range macro

0.0.2

  • Added trim value in range macro
  • Added safe malloc macro

0.0.1

  • First release

Latest podspec

{
    "name": "macros_blocks",
    "version": "0.0.4",
    "summary": "Useful macros for objective-c blocks.",
    "homepage": "https://github.com/belkevich/blocks",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Alexey Belkevich": "[email protected]"
    },
    "source": {
        "git": "https://github.com/belkevich/blocks.git",
        "tag": "0.0.4"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "5.0",
        "osx": "10.7",
        "tvos": "9.0"
    },
    "social_media_url": "https://twitter.com/okolodev",
    "default_subspecs": "core",
    "subspecs": [
        {
            "name": "core",
            "source_files": "macros_blocks.h"
        },
        {
            "name": "extra",
            "source_files": "macros_extra.h"
        },
        {
            "name": "all",
            "source_files": "macros_all.h",
            "dependencies": {
                "macros_blocks/core": [],
                "macros_blocks/extra": []
            }
        }
    ]
}

Pin It on Pinterest

Share This