ios - Parse: Create 1-to-1 relation on PFObject with support for multiple class types? -
i trying create pfobject subclass in parse has one-to-one relation pfobject in parse, relation support pfobject subclass. currently, create , save first pfobject parse, whatever pfobject connected set relation's 1 , accepted type, , creating second object connects different pfobject subclass relation generates error.
is there way either to...
- specify desired class one-to-one relation (i.e., pointer) should connect to? , if so, support connecting subclasses of specified class?
- create one-to-one relation supports kind of pfobject?
example:
for example, let's needed create subclass of pfobject called zookeeper
in addition multiple subclasses of pfobject various types of animals: armadillo
, bear
, camel
, etc. (and reasons must accept, each animal has have own pfobject subclass rather using generic animal
class).
then let's each zookeeper responsible 1 animal. this, want create one-to-one relation on zookeeper
called animal
can specify single animal object each zookeeper responsible for.
i create multiple zookeeper
, multiple animals. save first animal (an armadillo
) , first zookeeper
object ("alice") , second animal (a bear
), when try save second zookeeper
object ("bill") parse, following error:
invalid type key animal, expected *armadillo, got *bear
i not sure if want, you:
create animal subclass in parse, text field called "type", , 1 column each of different types of animals (yeah, know isn't elegant).
the column matching "type" column contains pointer specific animal object, while other columns nil.
to specific animal object, need animal object, @ type column, , @ corresponding pointer column specific animal object.
for example, zookeeper object contains pointer animal object. "type" column of animal object contains text "bear". retrieve object in "bear" column of animal object, bear object. meet specification? yes there animal object, there still notion of specific animal objects bear, etc.
Comments
Post a Comment