Changing the core data model versionIdentifier - iphone

I'm trying to debug an issue with my mapping model not being used by my migration, and so I printed out the sourceModel and destinationModel's versionIdentifiers, but both were blank.
http://developer.apple.com/library/ios/#documentation/cocoa/Reference/CoreDataFramework/Classes/NSManagedObjectModel_Class/Reference/Reference.html%23//apple_ref/occ/instm/NSManagedObjectModel/versionIdentifiers
This link says to set them in the model inspector but I can't find that on xcode 3 or 4... or at least there is no versionIdentifier or similar in anywhere I can find for the data model itself.
Does anyone know where I find that?

Take a look at this posting - and, in particular, my answer ;) : Core Data lightweight migration: Can't find or automatically infer mapping model for migration
I did not find versionIdentifiers to be as helpful in debugging as the 'metadata' for the various entities - as I outlined here: NSManagedObjectModel versionIdentifiers
Hope this helps.

Related

NsPerstentContainer name in Appdelegate conventions in Core Data setup

I'm programming my fist SwiftApp got stuck setting up Core data. Since I'm integrating it into existing code I can't have Xcode set it up on Prohect init anymore. Furthermore I als want to understand what the lines of code actually do. Since all Core libraries are secret I am stuck with Apple's Docs which are not very clear on the matter.
Pfew... with that out of the way here is the question; What is the significance of the name passed to...
let container = NSPersistentContainer(name: "Core_Data")
...in the App Delegate file. I had set it up before but during compilation Xcode complained that it could not find the specified Name's module. Changing it to my project's name, the core data file I had created or the name of the Database passed to the menu when adding a Core Data file did not seem to help at all. Searching the web and a few tutorials people just fly over it and it is still very much unclear to me.
Any help would be much appreciated!
The string passed there is used for two things. If you were to pass the string Foo, Core Data would attempt:
To find the data model by looking for Foo.xcdatamodel or Foo.xcdatamodeld.
To find (or create) the persistent store, using the name Foo.sqlite.
Even an incorrect string value (i.e. one that doesn't match the name of your data model) should not cause a compilation error. It might cause an error at run time if iOS can't find the named data model.

error when setting PostCodeGenCommand for a simulink model

I would like to add a post-build hook to my code generation process. However, when I try to associate a function with the simulink model's PostCodeGenCommand, I get the following error.
set_param(bdroot, 'PostCodeGenCommand', 'packNGo(buildInfo);')
A configuration set reference does not allow writing to parameters in the source configuration set
I don't really understand the error message, and it doesn't bring up any useful hits on my favourite search engine. Can anyone help me decipher it?
Unfortunately, I could not reproduce this problem on a simple simulink model, even if I included a reference model. (I thought that might be what the word "reference" was, um, referencing in the error message. And I've noticed previously that referenced models are handled differently to other models in the simulink code generator.)
I'm using R2015a, but have access to the newer versions if that would help.
Note that this question was originally posted on the Matlab forum, but didn't get any answers.
It turns out that the model was using a "configuration reference" rather than storing its configuration internally. The Model Explorer provides the following description
Configuration Reference
A model may reference a 'Configuration set' that is defined in the
source location rather than stored in the model....
This is useful for us because we use several models which all share the same configuration set. It's saved in a central place and all updates apply immediately to all models.
The side effect is that bdroot no longer has a PostCodeGenCommand associated with it. Instead, the command I was looking for was
configurationSettings.set_param('PostCodeGenCommand', 'packNGo(buildInfo);')
where configurationSettings is a variable in your workspace, and the variable's name should match the "Referenced configuration set name" in the Model Explorer.

iPhone Objective-C Error from Files Generated from Data Model

I created a data model in Xcode with about 9 entities, all of which are connected via relationships to a single 'core' entity.
Once I set this data model up graphically using the "Graph Editor Style" for the xcdatamodelId, I generated the class files by going to Editor -> Create NSManagedObject Subclass. I did this twice to establish all classes so there were no properties of type "NSManagedObject".
However without touching any of the generated files, I am getting 4 errors for one of my class entities (Style), all of which are:
Semantic Issue - Redefinition of 'Style' as a different kind of symbol.
Considering these files are generated, I'm more than confused as to what I need to do to fix these. The relationships between entities are straightforward, and there is nothing special about the 'Style' entity which differentiates it from the rest.
Is this possible due to the forward declarations in the various files? I'm stumped as how to rectify this - and I'm a beginner with iPhone development so I'm not quite sure how to approach this. Help is greatly appreciated!
You cannot create a class named Style
it is already defined on MacTypes.h
You should always prefix your classes with your own namespace i.e. Style should be DWStyle

Doctrine 2.1 abstract entity, validation using annotations

My name is Denis and I really need your help or advice or anything :)
I am developing my project in Zend Framework 1.11 and am using Doctrine 2.1.
I have successfully integrated Doctrine in my ZF project and everything works. I also integrated Gedmo extensions and some my custom extensions.
The problem is with validation. I want to have validation of doctrine entities by using annotations. Because I sometimes need to validate my entities sometimes don't, I want that sort of validation, for example:
$user = new Entity\User; $user->setName('user'); $user->validate();
I don't want to change doctrine generated entities at all, so I won't change setters or use doctrine events for this.#HasLifecycleCallbacks.
I run into example at http://www.spiffyjr.me/2011/07/15/more-doctrine-2-and-zend-framework-integration-goodies/.
I downloaded code but didn't managed to put it in work. I followed instructions from that page, made my entities extend AbstractEntity, but when try to use for example isValid() i recieve following error:
[Semantical Error] The annotation "#Column" in property Bild\Entity\TestTest::$id was never imported. Did you maybe forget to add a "use" statement for this annotation?
I use doctrine annotations without #ORM\, just #, (for example #Column, not #ORM\Column). I even tried to add ORM but no luck it continues to throw errors.
I can recieve metadata for my entity, get field mappings and associating mappings, but when I try to getPropertyAnnotation
// validator annotations
$vAnnotations = self::_getPropertyAnnotation($property, self::ZENDVALIDATION);
var_dump($vAnnotations);die;
I recieve mentioned semantic error.
I tracked the errors down to Doctrine\Common\Annotations\AnnotationReader::getPropertyAnnotations($property); not returning annotations but throwing errors.
What do you think it can be?
It seems like I am not doing something properly but can't figure out what.
So, I need to make abstract entity, make my entities extend it, and make functions to validate my entities by using annotations.
So please, help me with this, if you can. I really need for my project but couldn't find a solution.
Thanks in advance.
Best regards.
The problem is caused by the configuration of the annotation reader. I went through the same problems while integrating the Symfony2 validator service for my Doctrine2 models in ZF1, more on the blog post here http://ssmusoke.wordpress.com/2012/03/04/doctrine-2-day-2-model-validation-using-symfony-validator-service-in-zend-framework/

How to get an EntityCollection<class> instead of just a class?

I'm trying to convert a one-to-many relationship in entity framework to a many-to-many.
I've done the admin work and generated a database, which seems to be fine but now I'm running through the resulting errors and trying to get the code to compile. Most of it is fine, but one particular change is giving me a headache - I can't figure out the correct syntax. I'm sure I'm being very stupid here.
The original line was:
addedService.CompiledDatabase = context.Databases.OfType<CompiledDatabase>().First();
But addedService.CompiledDatabase is no longer looking for a single instance of CompiledDatabase, it's looking for a collection: an EntityCollection to be precise.
I can't figure out how to get a linq/lambda query that will return a collection of the required type. Assistance gratefully appreciated.
Something like?
addedService.CompiledDatabase.Attach(context.Databases.OfType<CompiledDatabase>());
...if addedService is already in context.