Latest 1.2.1
Homepage https://github.com/seivan/SHBarButtonItemBlocks
License MIT
Platforms ios 6.0, requires ARC
Authors

CI Status
Version
Platform
License

This pod is used by SHUIKitBlocks as part of many components covering to plug the holes missing from Foundation, UIKit, CoreLocation, GameKit, MapKit and other aspects of an iOS application’s architecture.

Overview

Category on top of UIBarButtonItem.

The blocks are automatically removed once the item is gone, so it isn’t necessary to clean up – Swizzle Free(™)

API

Init

Creating

Removing

Helpers and Properties

USAGE

Init

Creating

Removing

Helpers and Properties

Installation

pod 'SHBarButtonItemBlocks'

Setup

Put this either in specific files or your project prefix file

#import "UIBarButtonItem+SHBarButtonItemBlocks.h"

or

#import "SHBarButtonItemBlocks.h"

API

Init

#pragma mark -
#pragma mark Init
+(instancetype)SH_barButtonItemWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem
                                 withBlock:(SHBarButtonItemBlock)theBlock;

+(instancetype)SH_barButtonItemWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style
                   withBlock:(SHBarButtonItemBlock)theBlock;

+(instancetype)SH_barButtonItemWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style
                   withBlock:(SHBarButtonItemBlock)theBlock;

Creating

#pragma mark -
#pragma mark Add
-(void)SH_addBlock:(SHBarButtonItemBlock)theBlock;

Removing

#pragma mark -
#pragma mark Remove
-(void)SH_removeBlock:(SHBarButtonItemBlock)theBlock;
-(void)SH_removeAllBlocks;

Helpers and Properties

#pragma mark -
#pragma mark Properties

#pragma mark -
#pragma mark Getters
@property(nonatomic,readonly) NSSet * SH_blocks;

Usage

Init

Class convenience selectors for creating directly.

  UIBarButtonItem * button = [UIBarButtonItem SH_barButtonItemWithTitle:@"Clear blocks" style:UIBarButtonItemStyleBordered withBlock:^(UIBarButtonItem *sender) {
    [sender SH_removeAllBlocks];
    [sender SH_addBlock:^(UIBarButtonItem *sender) {
      SHBlockAssert(sender.SH_blocks.count == 1, @"Should have one block");
    }];
  }];

Creating

With SHBarButtonItemBlocks you can set auto-removed blocks instead of using selectors


  

or if you want add additional blocks

  ;

Removing

Remove specific blocks – will also remove the Event from the target if it was the last block

  [btnSecond SH_removeControlEventsForBlock:counterBlock];

Remove specific blockss

      ;

Remove all blocks

    [sender SH_removeAllBlocks];

Helpers and Properties


    // Unique blocks
  ;
  ;
  ;
  ;
  SHBlockAssert(button.SH_blocks.count == 3, @"Should have three blocks");

Contact

If you end up using SHBarButtonItemBlocks in a project, I’d love to hear about it.

email: [email protected]
twitter: @seivanheidari

License

SHBarButtonItemBlocks is © 2013 Seivan and may be freely
distributed under the MIT license.
See the LICENSE.md file.

Latest podspec

{
    "name": "SHBarButtonItemBlocks",
    "version": "1.2.1",
    "summary": "Prefixed UIBarButtonItem category with blocks, auto-removed. Swizzle free!",
    "description": "n                    UIBarButtonItem events with blocks.n                    Blocks are hold with a weak reference so you don't have to cleanup when your object is gone.n  n                    * Swizzle and junk freen                    * No need to clean up after - The control blocks are self maintained.n                    * UIBarButtonItems are referenced in a map with weak propertiesn                    * Auto remove control from outlets and all actions when removing all the blocksn                    * Prefixed selectors.n                    * Minimum clutter on top of the public interface.n                    n",
    "homepage": "https://github.com/seivan/SHBarButtonItemBlocks",
    "license": "MIT",
    "authors": {
        "Seivan Heidari": "seivan.heidar[email protected]"
    },
    "source": {
        "git": "https://github.com/seivan/SHBarButtonItemBlocks.git",
        "tag": "1.2.1"
    },
    "platforms": {
        "ios": "6.0"
    },
    "source_files": "SHBarButtonItemBlocks/**/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This