Git Product home page Git Product logo

Comments (3)

shidavid avatar shidavid commented on May 23, 2024

Swift也能使用, 只不过更新数据不能直接 object.property = xxx , 需要 object.setValue(xxx, forKey: "property")

from dvdatabind.

TheOtherSideOfTheSea avatar TheOtherSideOfTheSea commented on May 23, 2024

Swift也使用,但更新数据不能直接对象.property = xxx,需要 object.setValue(xxx, forKey: "property")

oc中的绑定是这样的
DVDataBind
._inout(self.demoModel, @"text")
._inout_ui(self.demoView.textField, @"text", UIControlEventEditingChanged)
._out(self.demoView.label, @"text")
._out_key_any(@"com.text", ^(NSString *text) {
NSString *pText = weakSelf.demoModel.text;
NSLog(@"demoModel 最新值为 %@", pText);
});

[self.demoView.button addTarget:self
                         action:@selector(onClickForButton:)
               forControlEvents:UIControlEventTouchUpInside];

那么,在swift中应该怎么写绑定这块?image
swift中DavDataBind._inout方法没有第二个参数

from dvdatabind.

shidavid avatar shidavid commented on May 23, 2024

Swift也使用,但更新数据不能直接对象.property = xxx,需要 object.setValue(xxx, forKey: "property")

oc中的绑定是这样的
DVDataBind
._inout(self.demoModel, @"text")
._inout_ui(self.demoView.textField, @"text", UIControlEventEditingChanged)
._out(self.demoView.label, @"text")
._out_key_any(@"com.text", ^(NSString *text) {
NSString *pText = weakSelf.demoModel.text;
NSLog(@"demoModel 最新值为 %@", pText);
});

[self.demoView.button addTarget:self
                         action:@selector(onClickForButton:)
               forControlEvents:UIControlEventTouchUpInside];

那么,在swift中应该怎么写绑定这块?image
swift中DavDataBind._inout方法没有第二个参数

let view : UIView = UIView()
MyDataBind
._in()(self, "hello")
._inout_ui()(view, "property", UIControlEvents.touchUpInside) // 比OC多加一个()

这里必须用 .setValue设值,不能 view.property 直接赋值
view.setValue("123", forKey: "property")
self.setValue("456", forKey: "hello")

from dvdatabind.

Related Issues (3)

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.