Создание JSON путем объединения полей из двух классов

Вы также можете попробовать следующее:

- (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event { 

    for (id textField in self.view.subviews) {

        if ([textField isKindOfClass:[UITextField class]] && [textField isFirstResponder]) {
            [textField resignFirstResponder];
        }
    }
} 

Я не пробовал, но кажется хорошим решением

2
задан ASharma7 23 February 2019 в 02:22
поделиться

2 ответа

Как насчет использования jackson @JsonUnwrapped?

http://fasterxml.github.io/jackson-annotations/javadoc/2.0.0/com/fasterxml/jackson/annotation/JsonUnwrapped.html

public class A{

    @JsonUnwrapped
    private B b;

    public User getB() ...
}
0
ответ дан Sanjay 23 February 2019 в 02:22
поделиться

Создайте делегирующий класс AB:

public final class AB {
    private final A a;
    private final B b;
    public AB(A a, B b) {
        this.a = a;
        this.b = b;
    }
    // Delegation methods to A
    public int    getF1() { return this.a.getF1(); }
    public String getF2() { return this.a.getF2(); }
    // Delegation methods to B
    public int    getF3() { return this.b.getF3(); }
    public String getF4() { return this.b.getF4(); }
    public String getF5() { return this.b.getF5(); }
}
0
ответ дан Andreas 23 February 2019 в 02:22
поделиться
Другие вопросы по тегам:

Похожие вопросы: