Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Method That Allows for Broadcasting When STAButton State Changes #1

Open
Stunner opened this issue Jun 6, 2015 · 2 comments

Comments

@Stunner
Copy link
Owner

Stunner commented Jun 6, 2015

If you look at the reference link for the STAButton class. You'll notice that the original author baked in the capability to broadcast when the state of the button changes by hijacking Apple's UIControlEventState... enum, which I am not a fan of.

Implement this broadcasting capability by providing a method that the user of the button can use to register a block that gets called whenever the Button's state changes. The block should have 2 parameters, one for the old state value, and one for the new state value.

Bonus Points if you write a test case for this method (doesn't have to use KIF).

@dhsu123
Copy link
Contributor

dhsu123 commented Jun 7, 2015

HI Aaron,

I did something like the below but didn't push it yet. I need to learn how to use ios testing.. let me read a tutorial tomorrow on it.

*.h:
typedef void (^ StateChangeBlock)(UIControlState, UIControlState);
-(void)registerForStateChangesWithBlock:(StateChangeBlock)block;

*.m:
-(void)registerForStateChangesWithBlock:(StateChangeBlock)block{
if (block!=nil){
block(self.priorState,self.state);
}
}

Date: Sat, 6 Jun 2015 08:20:38 -0700
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: [STAControls] Implement Method That Allows for Broadcasting When STAButton State Changes (#1)

If you look at the reference link for the STAButton class. You'll notice that the original author baked in the capability to broadcast when the state of the button changes by hijacking Apple's UIControlEventState... enum, which I am not a fan of.

Implement this broadcasting capability by providing a method that the user of the button can use to register a block that gets called whenever the Button's state changes. The block should have 2 parameters, one for the old state value, and one for the new state value.

Bonus Points if you write a test case for this method (doesn't have to use KIF).


Reply to this email directly or view it on GitHub.

@Stunner
Copy link
Owner Author

Stunner commented Jun 7, 2015

Don't worry about writing unit tests for it. Instead ensure that it works as it should manually. You should be able to do that by placing an NSLog statement in the body of the registered block. Run the sample app and go to the STAButton view and you should be able to tie in demo-related test code in there to help validate that your work works. Unit tests should be done in a different commit altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants