GithubHelp home page GithubHelp logo

Comments (9)

terryworona avatar terryworona commented on June 16, 2024

So you want a dictionary property added to each instance of the message view?

Perhaps I'm misunderstanding the need, but model/payload information shouldn't be included in any view-specific classes; basic MVC.

Model-specific logic can exist outside the "show" call and be referenced within the tap callback. Wouldn't this suffice?

from twmessagebarmanager.

cdzombak avatar cdzombak commented on June 16, 2024

I'd be interested in hearing more about the use case here; I suspect there's another way to solve your problem without adding model state to this view.

(For sake of argument, I've been trying for a few minutes to come up with a UIKit API that might provide some sort of precedent for this pattern, but I can't think of any.)

from twmessagebarmanager.

wdcurry avatar wdcurry commented on June 16, 2024

I think the use-case is quite standard for moderately complex apps. A push notification is received and processed, while the app is active. The user may or may not want to respond. So we toss out a notice. If the user taps it, we know they are engaging, thus we must act on the payload provided by the original push. I suspect a simple __block dictionary will manage this process. I think i was getting confused between reviewing a bunch of libraries today and had this one mixed with another that centralized responses rather than a local block.

So.. __block the payload dictionary, await the engagement and with the code block use the __block variable.. sound about right? (i am a moderate newbie to this platform)

from twmessagebarmanager.

terryworona avatar terryworona commented on June 16, 2024

To re-iterate, model and view should remain mutually exclusive.

A MVC solution:

appDidReceiveRemoteNotification:(id)notification...{
     id payload = notification.payload;
     if (payload.notificationType == type1){
        [[TWMessageBarManager sharedInstance] show... callback:{
            // user clicked - we have all info we need from the payload
            [self presentViewOfType:type1 withPayload:payload];
        }];
    }
}

from twmessagebarmanager.

wdcurry avatar wdcurry commented on June 16, 2024

thanks terry, similar to what i described after i explained my brain-fart earlier. Only diff is that i was under the assumption only __block vars are accessible inside of callback blocks?

from twmessagebarmanager.

terryworona avatar terryworona commented on June 16, 2024

@wdcurry correct, so just declare a few __block vars prior to presenting the message:

_block NSDictionary *payloadBlock = notification.payload;

from twmessagebarmanager.

cdzombak avatar cdzombak commented on June 16, 2024

Only diff is that i was under the assumption only __block vars are accessible inside of callback blocks?

No, __block doesn't have anything to do with accessibility. You can capture variables inside callback blocks without any special notation. See this Stack Overflow answer for some additional explanation.

from twmessagebarmanager.

wdcurry avatar wdcurry commented on June 16, 2024

thanks kindly cd.. i enjoy learning something new every day ;)

from twmessagebarmanager.

cdzombak avatar cdzombak commented on June 16, 2024

i enjoy learning something new every day ;)

As do I 😄

from twmessagebarmanager.

Related Issues (20)

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.