Latest 0.1.3
Homepage https://github.com/EricYellow/GEPoster
License MIT
Platforms ios 8.0
Authors

logo

CI Status
Version
License
Platform

Description

Replacement for NSNotificationCenter !

In order to take full advantage of the system notification tool, I made this library specifically.
This library mimics the usage of system notification, while extending the userInfo parameter.

Example

Subclass GEPoster , and then you can use it like this:

  1. Create your notification methods and Poster instance

import

@protocol MyNotification1

@optional

  • (void)controllerDidReceiveSomething:(NSString *)something;
    @end

@class Model;
@protocol MyNotification2

@optional

  • (void)controllerDidReceiveSomeModelInfo:(Model *)info;

@end

@protocol MyNotification<MyNotification1,MyNotification2>@end

@interface MyPoster : GEPoster
@end


2. Use the poster like this:

```objc
#import "GEViewController.h"
#import "MyPoster.h"

#import "Model.h"

@interface GEViewController ()<MyNotification1>

@end

@implementation GEViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [MyPoster registObserver:self];
}

- (void)controllerDidReceiveSomething:(NSString *)something
{
    NSLog(@"%@", [NSString stringWithFormat:@"did Receive somethion:%@",something]);
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{

    NSLog(@"touched.....");

    Model *info = [Model new];
    info.name = @"Hello Gloria";
    info.isMale = YES;
    [[MyPoster share] controllerDidReceiveSomeModelInfo:info];

    // or 
    dispatch_async(dispatch_get_global_queue(0, 0), ^{

        for (int i  = 0; i < 100; i++) {

            dispatch_async(dispatch_get_global_queue(0, 0), ^{
                NSLog(@"第%zd次",i);

                [[MyPoster share] controllerDidReceiveSomething:[NSString stringWithFormat:@"这是我发送的第 [%zd] 个通知",i]];

            });

        }
    });
}

@end

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

GEPoster is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'GEPoster'

Author

[email protected]

License

GEPoster is available under the MIT license. See the LICENSE file for more info.


说明:

鉴于系统通知使用不便, 我特地制作了这个库, 你可以像使用系统通知一样使用这个库.同时你可以得到如下特性:

  • 1.不需要remove observer.
  • 2.我扩展了系统通知的userInfo这个参数, 你可以写任意参数.

具体使用,请参考上面英文部分.

Latest podspec

{
    "name": "GEPoster",
    "version": "0.1.3",
    "summary": "Replacement for  NSNotificationCenter !",
    "description": "This Framework extending Notification's userInfo parameter!",
    "homepage": "https://github.com/EricYellow/GEPoster",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "[email protected]": "[email protected]"
    },
    "source": {
        "git": "https://github.com/EricYellow/GEPoster.git",
        "tag": "0.1.3"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "GEPoster/Classes/*"
}

Pin It on Pinterest

Share This