java - Equivalent in Objective c of BeanUtils.copyProperties. -
i know if have equivalent in objective c of java's methode "beanutils.copyproperties(bean1, bean2);" ?
or other solution, cast motherobject childobject :
@interface motherbean : nsobject{ ...} @interface childbean : motherbean { ...} motherbean m = [motherbean new]; childbean f = m; with first tests it's work have warning : "incompatible pointer types returning ...";
i use wsdl2objc , generate bean, , name of can change between 2 generation :-/
i prefere work child , change name in definition
thanks
anthony
take @ commons-beanutils package. has lots of property method copy stuff. in particular:
propertyutils.copyproperties(bean1, bean2); however, second question, you're trying downcast instance of parent class child class?
i'm not sure how legal in oo language. sure can forcibly cast:
// not legal because can't case 1 class anther // unless actual instance type (not declared type of variable, // constructed type) either casted class or subclass. parent p = new parent(); child c = (child) p; but you'd classcastexception , since can't treat instance of parent class if child class (only other way around). either of these legal however:
// legal because you're upcasting, fine child c = new child(); parent p = c; // legal because instance "p" // instance of "child" class, downcast legal. parent p = new child(); child c = (child) p;
Comments
Post a Comment