Skip to content

Commit

Permalink
Merge pull request #4696 from srahim/TC-2945-31X
Browse files Browse the repository at this point in the history
[TIMOB-15205]  3_1_X iOS7 : Fire change event when there is actually a change in value.
  • Loading branch information
WhichKatieDid committed Sep 16, 2013
2 parents f698708 + ab806b0 commit c35b513
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions iphone/Classes/TiUISwitch.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ -(void)setCenter:(CGPoint)center
- (IBAction)switchChanged:(id)sender
{
NSNumber * newValue = [NSNumber numberWithBool:[(UISwitch *)sender isOn]];
[self.proxy replaceValue:newValue forKey:@"value" notification:NO];
id current = [self.proxy valueForUndefinedKey:@"value"];
[self.proxy replaceValue:newValue forKey:@"value" notification:NO];

//No need to setValue, because it's already been set.
if ([self.proxy _hasListeners:@"change"])
if ([self.proxy _hasListeners:@"change"] && (current != newValue) && ![current isEqual:newValue])
{
[self.proxy fireEvent:@"change" withObject:[NSDictionary dictionaryWithObject:newValue forKey:@"value"]];
}
Expand Down

0 comments on commit c35b513

Please sign in to comment.