markohlebar / BIND

Data Binding and MVVM for iOS
MIT License
355 stars 48 forks source link

Fixing transform block assign when set view model #11

Closed ducker closed 9 years ago

markohlebar commented 9 years ago

Hey @ducker thanks for the PR and spotting the issue. I would like to look at a more elegant way of solving this though. Would simply removing self.transform = nil work? As in

- (void)unbind {
    [self removeObservers];

    self.leftObject = nil;
    self.rightObject = nil;

    [BNDBindingObject_bindings removeObject:self];
}

I think that preserving the transform should probably be the default behaviour anyways. What do you think?

ducker commented 9 years ago

Hi,

I was thinking about just removing that line, but I don't know all usecases so I decided to make another method just to refresh binding when assigning view model. I couldn't find a better way to keep reference to transform block and I agree that it doesn't look good. It was just a quick hack in my project and to be honest I accidentally created pull request to your branch instead of mine. I wanted to open git issue in your repo but I just left PR. I don't see any potential issues with code above so maybe it's better solution.

2015-04-16 21:48 GMT+02:00 Marko Hlebar notifications@github.com:

Hey @ducker https://github.com/ducker thanks for the PR and spotting the issue. I would like to look at a more elegant way of solving this though. Would simply removing self.transform = nil work? As in

  • (void)unbind { [self removeObservers];

    self.leftObject = nil; self.rightObject = nil;

    [BNDBindingObject_bindings removeObject:self]; }

I think that preserving the transform should probably be the default behaviour anyways. What do you think?

— Reply to this email directly or view it on GitHub https://github.com/markohlebar/BIND/pull/11#issuecomment-93824686.

markohlebar commented 9 years ago

@ducker yeah I see that you took the conservative approach :) If you have time to test and make the above stuff into a PR I would appreciate it. Cheers!

markohlebar commented 9 years ago

@ducker good stuff thanks!