GithubHelp home page GithubHelp logo

dovmess's Introduction

DovMess

CI Status Version License Platform


    An easy way to send callback message from UIView to UIViewController.

Scenario


    You have a UIViewController that includes a UIView name firstView. FirstView includes secondView, secondView includes thirdView, thirdView includes fourthView, fourthView includes fifthView. Then, there is a button in the fifthView, and such action callback is in the root(UIViewController). Like below:

|UIViewController
| | | FirstView
| | | | | SecondView
| | | | | | | ThirdView
| | | | | | | | | FourthView
| | | | | | | | | | | FifthView
| | | | | | | | | | | | | Button

    Usually, there are two solutions to handle the action from Button to UIViewController:
#####No.1
    Adding delegates to every UIViews between Button and UIViewController. This would generals massive code in the middle.

#####No.2
    Button sent a notification, and UIViewController observes it.However, this may not as you wish because this beyonds your design since everybody could receive this notification message.
DovMess provides you the third way to handle it.

Adding DovMess to your project


    The simplest way to add DovMess to your project is to use CocoaPods.
Add the following line to your Podfile:

	pod 'DovMess'

    If you'd prefer to manually integrate it, just copy 'Pod/Classes/*.{m,h}' into your project.

Adding Message Sender


    In the example we described above, just add button clicked action in the fifthView for button click:

- (void)buttonClicked {
    DOVMessage *message = [[DOVMessage alloc] initWithName:@"ViewController.holy" from:self];
    [DOVMessageBus sendMessage:message];
}

    In this example, message name described the filterReceiver("ViewController") and the signal name("holy").

Adding Message Receiver


    In the example we described above, just add DovMess Message Handler:

DOVE_MESSAGE_HANDLER2(ViewController, holy, message) {
    NSLog(@"I'm ViewController , I already handled this message");
}

    Then finished!

How It Works


    While sending a message from view, DovMess will search UIView's NextResponder, and see whether this NextResponder could responds the method(selector).

Example


    See example in the Example Folder.

Changlog


0.1.1

  • Bugfix for instance method

0.1

  • Initial release

License

Copyright © 2015年 Rajax Network Technology Co., Ltd. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Contacts


Any Questions, just send e-mail to me: [email protected]

dovmess's People

Contributors

cendywang avatar

Watchers

James Cloos avatar Harimoto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.