iPhone Coredata saving error - iphone

I'm trying to create core data application.
Some times when trying to save data, i'm seeing following error:
Error: NSInvalidArgumentException,
Reason: * -_referenceData64 only defined for abstract class. Define -[NSTemporaryObjectID_default _referenceData64]!,
Description: * -_referenceData64 only defined for abstract class. Define -[NSTemporaryObjectID_default _referenceData64]!
I didn't understand why this error is coming and how to avoid it. Can some one help me please.

Edit: The original answer below is technically correct but doesn't accurately describe the true source of the error. The runtime can't find the correct attribute but the reason it can't find it is because the entity exist in another managed object context. The OP probably never had a _referenceData64 attribute for any of his entities.
See: http://www.cocoadev.com/index.pl?TemporaryObjectIdsDoNotRespondToReferenceData
Original Answer:
You have a class that has an attribute _referenceData64. In the data model, that class is marked as "abstract'. Select the entity in data model editor and check the box below that says "abstract". If it is checked, then that is your problem.
An abstract entity is never instantiated. Unless is has a subclass, you can't actually set its attributes to any value. Abstract entities just exist to provide templates for subclasses.

Related

Relationship of a class which creates object to the created object UML

I am not sure which relationship between classes would be adequate for a class which returns a created object or gets an object as parameter(see uploaded picture). I guess that aggregation/composition is wrong since Class1 does not own the object/does not have it as an attribute. Also I think that an association is wrong since Class1 does not refers to a pointer.
Thank you in advance for any answers.
That would simply be dependencies:
An association is created in case you have a stronger relation between classes. That is either one is holding a more permanent relation (in form of an attribute) rather than a temporary one like in using them as passing parameter or return parameter. From an UML point of view an association is basically a stronger form of a dependency.
Note that the untyped attributes you sketched are of no interest in this context and I just left them out.
According to a comment of #www.admiraalit.nl: If Class1 creates new instances of Class3, the dependency may have the ≪create≫ stereotype, see table 22.1 of the UML spec. v2.5.1. In that case the dependency would be a usage (chap. 7.8.23) which is just a bit stronger
a class which returns a created object or gets an object as parameter(see uploaded picture)
you mean for a class having an operation returning ... and an other getting ...
I guess that aggregation/composition is wrong since Class1 does not own the object/does not have it as an attribute
you are right
Also I think that an association is wrong since Class1 does not refers to a pointer.
whatever by pointer or by value (which is target language dependent) an association is not right because there is no attribute in Class1 whose type is Class2 or Class3
The only possible relation between Class1 and Class2 or Class3 seems to be a dependency, but to have them does not have a real plus value, the profile of the operations already give that information

entityName.state must have a defined type

I am new in doing coreData programming, i followed a tutorial and was doing step by step, while i got this error and got stucked up, Dont know what this means
entityName.state must have a defined type
entityName.zip must have defined type
You have not set the datatype for the entity, meaning that CoreData does not what type the property is.
In your CoreData model make sure that the Attribute Type is set and recreate you CoreData files.

C# dynamic type how to access some methods and slef tracking entities

I have use the type dynamic, a new type in .NET 4.0.
I want to use a dynamic type because I want to use some types that in advance I don't know what type is, but I know that all this possible type has some common methods.
In my case, I am using self tracking entities in entity framework 4.0, and I know that all the entities has the methods markedXXX (to set the state of the entity).
Through the dynamic object that I created, I can access and set the properties of one of this entities, but when I try to execute the MarkedAsXXX method I get an exception that says that the object has not definied the method.
I would like to know how to access to this methods. Is it possible?
Because I have a function that can access to the original values and set this values to the current one, but I need to set the entity as Unchenged.
Thanks.
I want to use a dynamic type because I want to use some types that in advance I don't know what type is, but I know that all this possible type has some common methods.
That suggests you should create an interface with those common methods, and make all the relevant types implement the interface.
Through the dynamic object that I created, I can access and set the properties of one of this entities, but when I try to execute the MarkedAsXXX method I get an exception that says that the object has not defined the method.
It's possible that this is due to explicit interface implementation. If the types have those methods declared as public methods in the normal way, it should be fine.
If you really want to use dynamic typing with these types, is there some base interface which declares the MarkedAsXXX methods, which you could cast the objects to before calling those methods? (I'm not familiar with the entity framework, so I don't know the details of those methods.)
Basically, I would try to avoid dynamic typing unless you really need it, partly because of edge cases like this - but if explicit interface implementation is the cause, then casting to that interface should be fine.
If you define an interface to the dynamically generated classes you can call the methods without the hassle of reflection calling.

OWL: Defining attributes and member objects of a class

I am totally new to the domain of semantic web and need to create an ontology.
I did a lot of research, but still didn't find a clear solution to the following problem:
Basically, I want to describe semantically, that a certain class contains certain objects and attributes. But it's not 100%ly clear to me how to do that.
Example: I want to describe the class "device". Now this class contains an object "application", and an attribute "ID".
I got as far as mapping the object "application" to an ObjectProperty "hasApplication", and the attribute mapped to a DatatypeProperty "ID". So far so good, but now how do I bind them to the class?
There were two main ways I found:
Either you include the class name as domain in the definition of a property.
Or you include the properties into the class definition via owl:Restricion/owl:onProperty.
But in my opinion, both ways do not capture accurately my semantic intention, because in the first case, I understand it as, that if ever an object uses the defined property, then this object has to be an instance of the class defined in the domain, BUT that does not necessarily mean that every instance of this class must have this property.
Similarly, in the second case, binding a property to a class via owl:Restriction/owl:onProperty, imposes that I put a restriction on this property, i.e. cardinality or range of values. But that is not my intention, I do not want to describe "This class has this property with this restriction.", but simply "This class has this property."
Hope you guys can clear things up a bit. :S
Going with your example, you have a class Device, and you have a class Application and an ObjectProperty for relating them. In OWL Manchester syntax:
Class: Device
Class: Application
ObjectProperty: hasApplication
It's a bit misleading to think about Applications in terms of 'object contained in the Device class'. Think of them rather as objects related to that class.
Now, you can make the relation between Devices and Applications globally available by setting the domain and range of your property:
ObjectProperty: hasApplication
Domain: Device
Range: Application
However, this may not quite be what you're after, since this only says that if a hasApplication relation occurs anywhere, its subject and and object can be inferred to be of type Device and Application, respectively. It does not say that all instances of Device must have a hasApplication property.
To express that all instances of Device must have a hasApplication property, you can use an OWL cardinality restriction:
Class: Device
SubClassOf: hasApplication min 1
This tells us that any instance of Device must have at least 1 hasApplication property.

morphia annotation

I am using mongodb with java and also morphia.
For my usecase i get collection name at run time. So i have a enum of collection names and based on some value i get the corresponding collection name from enum. My entity annotation is as follows
#entity(EnumName.getCollectionName())
But i get the following error
"The value for annotation attribute Entity.value must be a constant expression"
I am actually returning a constant expression only. Could anyone let me know what the issue is.
You can't use some something dynamic within annotations as those are "compile" time features which can't be changed afterwards. So you can only handle constants which you declared there, Enums and Classes. For this a smart compiler may be able to find out that you handle something which may never change, but most wont and will simply error as soon as they see that you're trying asign some function value to an annotation property.
I don't really understand what you're trying to do, but it somehow looks like you try to use one "generic" entity class for several concrete entities. I think this is really bad design.
If you can tell more details, we may be able to give you a proper solution for your problem.
If you simply don't know what Class you have to operate with at runtime, try this.
Declare your concrete entities and fill your enum with those Classes. At Runtime you can do Datastore.find(Enum.YOURCLASS) and morphia will query your appropriate class.