Core Data question

Hi all,
I'm hitting a wall trying to figure out how to do this, so hopefully someone can point me in the right direction... I'm also a bit new to Cocoa/Obj-c programming so hopefully this isn't too obvious
I'm building a core data document based app and have my data model designed but I realized that quite a bit of the data should be separate and shared across all documents created in the app. I'd think the easiest way would be to put those entities in a separate data store and load it concurrently in any open documents, but have it be part of the base data model. I'll try to clarify what I'm getting at:
The user can have multiple documents, and possibly multiple open at any given time, and I'll try to use a simplified example
The entities for this application are
Project
ExpenseLog
ExpenseLineItem
Categories
Vendors
The relationships are
ExpenseLog <--->> ExpenseLineItem
ExpenseLog <<---> Vendors
ExpenseLineItem <<---> Categories
Each project gets it's own file, and the application is tracking expenses (think of an ExpenseLog row as an invoice.) Most projects will have common categories and common vendors, but the ExpenseLog is unique to the project. If a user adds a vendor or category to a project, it should add it to the Vendors or Categories entity and be available across all other projects.
From what I was able to find so far, there should be a way to do this, but I have yet to find any detail on how... The second question I have, is that for an application like this would it be better (definitely easier, but better in terms of user experience) to just have a single document that contains all projects and set up a Project <-->>ExpenseLog relationship?
thanks!

Hrm, let me try to rephrase this and see if I can make it clearer...
The application is a core data document based one. The idea is that there is some data that is common to all documents, and some that is unique. I'd like to store the common data in one file that is loaded and accessable across all open documents, and the unique data in each documents own file.
If I open expenselog1 and expenselog2 both documents should have the same list of vendors and categories. If I add a vendor to expenselog1, it should become available in expenselog2 and vice versa. If I open a new document, expenselog3 it should also see all of the above vendors and categories. If I add an entry to expenselog1, it should only be added to that document and saved in it's own file.
I've found some stuff on entity configurations, but apples documentation (at least what I've found so far) has little substance on this point and contains circular references (i.e. car: see automobile, automobile: see car) Also, it states that you can not create cross store relationships. Is the idea that you put an entity into multiple configurations and then if the entity is updated, both configurations are also updated? Or do you have to write code that updates both configurations discretely? Also, all the references I have found so far say to set the configuration for an entity, but it doesn't say how to configure the configuration to access a particular store.
What I'd like is that there is a common file that contains the common entities and a separate file that contains the individual documents so that the documents have access to the common elements.
Thanks.

Similar Messages

  • Core Data questions (NSNumber)

    Hi,
    I'm a bit lost with cocoa programming (have done C/C++ in University, now trying to get into the whole user interface thing). I'm trying to do a simple Core Data application but there are things I don't understand.
    First, I have an NSForm in my main window. I'd like the user to enter values in those. But, one of my entitie's attribute should be an interger. The thing is, the values in an NSForm field is a string. I know I can switch the attribute's type to string, but is there a proper way of doing this?
    Second, I have an NSTextField that shows an integer (again it's a string, I'd like it to be an integer). I placed a button next to it to increment that number by one each time it's clicked. At the same time, that field is binded to an attribute wich I'd like to be updated each time to keep track of everything. How do I program the incrementation thing in cocoa? I know Objecive-C quite a bit, but I don't know how to get the job done (what to connect to what, where to put my code, what to overide, etc...).
    Any help would be appreciated!

    Well, first of all, most interface components in Cocoa inherits from the class NSControl, in this class you can fin the method -intValue and -setIntValue: to respectively get and set an int value, if you send an -setIntValue: message to a text field it'll display your integer as a string. If you send a -intValue message to a text field it'll try to parse the number in the text field and will return it or 0 otherwise.
    For your incrementing I would tell you to use bindings, but in that case I would let you read the Apple Documentation because I never really use it so I can't explain it properly.
    So, I'm going to tell you the traditional way to make that work. According to MVC design pattern (Model-View-Controller), you would use 3 levels, but I'll make it simpler and use only 2.
    You have to create a new class which will be a Controller, to do this you go into Interface Builder, in the MainMenu.nib you click the Classes tab, you select NSObject in the left column, you go Classes menu and you do "Subclass NSObject". You put a name for your class.
    Then you open an inspector window, you go in Attributes part where you can see outlets and actions. You add one outlet for your text field of type NSTextField, and you add one action named increment: (the colon is added automatically).
    Then you click on your class again in the MainMenu.nib Classes tab and in the Classes menu you choose Instantiate <your class name>. You'll see a blue cube appear in the Instances tab.
    You hold ctrl key and click on the cube then you drag to your NSTextField (a line should appear between the cube and the cursor) you drop the line on the NSTextField and connect the text field to the outlet in your inspector window.
    You do the same for the button, except that this time you drag from the button to the blue cube and you select the action you defined earlier.
    There you are, everything is set up in IB, now go back into the Classes tab, select your class again and in Classes menu choose "Create files for <your class name>", choose your project and validate. Close IB and save your nib, go on Xcode, select <your class name>.m and inside it put the code into your increment method :
    [textField setIntValue: [textField intValue] + 1];
    textField should be replaced by the name of the outlet you put. Then you can execute and you'll have a beautiful text field which value will be incremented by clicking on the button.
    You can check the Cocoa Tutorial in Apple documentation, there's way more in it than in my post, and there's illustrations to make everything clearer.

  • Core Data and migration question.

    Lets say software v1.0 uses the core data model version coreDataModelA.xcdatamodel ...
    Software v2.0 uses core data model version coreDataModelB.xcdatamodel...
    and Software v3.0 uses core data model version coreDataModelC.xcdatamodel.
    Assuming migrations were done from coreDataModelA.xcdatamodel to coreDataModelB.xcdatamodel and then to coreDataModelC.xcdatamodel, if a user is upgrading from software version 1.0 to software version 3.0 (skipping 2.0).... will it successfully migrate for them?
    I'm assuming an app has only one xcmappingmodel file.

    Does this help?

  • Best path for Core Data implementation

    Hi all,
    First post so pls go easy!
    I'm a seasoned Windows/Web App developer who has recently (3-4m) discovered Mac, Cocoa and Obj-C. I've been buried in Apple docs, Hillegass and Dalrymple books for some time now trying to get to the point where I'm ready to build the Cocoa project that I have in mind, which looks to be well suited to a Core Data based Application driven by SQLite. The data model is reasonably complex with around 10 inter-related entities which must retain data integrity.
    Anyway, onto the question... historically I would have built a class library to encapsulate the use of the data model and accessed that class library when events fired to do what needs to be done. The Cocoa solution appears to support this - presumably though creating my own framework that is then referenced by the Cocoa application. I can see though that there is another path where I skip the encapsulation and build a Core Data based Cocoa app directly.
    At a high level - is there a preference between the two approaches?
    The latter seems well documented/supported but I am synically thinking that is because it is more straightforward and clearly faster, are there other advantages such as performance.
    For background the app when running will follow similar form to Mail.app in terms of multi-view with some data tables and custom views in play.
    Thanks,
    Chris

    Hi K T - thanks.
    Bottom line I think is that encapsulation is a safety blanket that I probably need to let go of. CD ticks boxes on a theory level, subject to implementation not being too heavy it seems like the logical step. The only consideration was to encapsulate a framework built on the known methods, then move the framework to CD under the covers when ready - that seems a bit gutless though and almost definitely inefficient time wise. I guess that there is little point in encapsulating CD from the outset - feel like it just adds unnecessary work in addition to some degree of performance overhead?
    {quote}Are you looking for flexibility or performance, by the way?{quote}
    Performance - the data model is unlikely to change once bedded in beyond addition of properties etc very infrequently. The app is likely to need to handle many tens of thousands of rows of data (albeit small in terms of data volume per row) for some users, and my conclusion from the documentation was that SQLite is the most appropriate route if committing to CD where data volume and/or relationships are plentiful. Is that a fair assessment?
    {quote}Are you looking to mimic traditional application interfaces or to adopt trends that are currently unfolding?{quote}
    The app I plan to build desperately needs to be brought up to date - possibly even beyond the advanced UI that AppKit seems to offer by default IMO. That said I don't want to overcommit on the extent of the build, but I do want to turn heads without just slapping coverflow or similar in for the sake of it. If you have any references or examples for doable leading edge UI design on OSX they would be gratefully received.
    Thanks again for your help - really appreciate it.
    Chris

  • Using core data with a database

    Here is where I am at. I have a trivia app in development that will have over 1000 questions, so a database is inevitable. We recently created a test sqlite database and read in some entries and it worked.
    We were looking into exploiting the features of Core Data in our app, but this would involve creating a set of managed objects, a context, and the essentials for a Core Data scheme to function, and then use these models to fetch data from a database.
    The database is not created yet. We are starting fresh and simply wish to see if we can use core data to work with a database that could be created once the model is in place. Is it possible to create a 1000 or more entry database whose entries could relate to a Core Data entity or set of entities, and then use Core Data to fetch the data from these entries as we please?

    We will not be reusing any code. I apologize for the confusion. This is the start of the app regarding database management, and we have not yet created the database that will hold the questions for this app.
    Alright, so you two are both suggesting to set up a model and allow the creation of the sqlite store, which if my research is correct, involves a .sqlite file with a "Z_" following each attribute, and then adding entries here. This sounds fair enough. I had not known if this was going against the mainstream use of core data or not.
    Thanks you two. I'm going to leave the question open for a little while longer to see if any other opinions come up.

  • Edit and save a Core Data entity?

    Sorry if this is a fairly obvious issue, but I honestly can't find anything..
    Every sample Core Data application I've come across has examples of inserting and deleting entities/objects. But I cannot find anything about editing and saving some attributes of an existing object. Is this possible??
    I'm using default core data/managed objects, not custom classes yet. I can insert, view, and delete objects from the context. But I want to be able to edit attributes, and NOT in a table cell. I want to open the object in a separate window (which I can do), edit the attributes in that window, and click a "Save" button to update the attributes of that particular object. I can't find anything that shows me how.
    I am thinking a work-around would be to remove the existing object and just create a new object with the data, but if I have relationships to other objects, it seems like doing that would mess them up. My other train of thought is, if I can't do this with default core data objects, what CAN I do it with? Do I need to create custom classes for the objects, or do I need to use an SQL database separately?
    Thanks...

    Apple has this to say about that...
    Entity-relationship modeling is a way to describe data structures that can be mapped to an object-oriented system. Since it comes from the database world, there is some terminology that is associated with it that you may not be familiar with. These terms are:
    Entities, specific pieces of information in a data model.
    Attributes, the components of an entity. These are usually simple scalar types, such as int, float, or double; C structures such as char *, NSPoint; or an instance of a primitive class, such as NSString, or NSNumber.
    Relationships, references that an entity can have to other entities. These relationships can be optional or required as well as one-to-one or one-to-many.
    Properties, a collective term for attributes and relationships.
    -=-
    Entities and Managed Objects
    Each entity definition in a managed object model requires the name of the entity and the name of the class used at runtime to represent that entity.
    http://developer.apple.com/macosx/coredata.html
    do I need to use an SQL database separately?
    Core Data support three different kinds of data store formats to save managed objects contexts to. These formats are:
    • XML file format
    • Binary archive file format
    • SQLite database file format
    ...which are you using now? That is a rhetorical question for you to ponder, actually.

  • Core Data - Save and Load

    Hi
    I need to add functionality to my iPad app so that I can save and load notes from a UITextView then load them when the user selects the date in the UIDatePicker that it was originally saved on, much like a calendar, notes for different dates.
    I have asked around on StackOverFlow and people have been spoon feeding me code samples but I am not quite latching on. Complain all you like, but I really want to learn how to do this, however currently its fairly important that I get the functionality added in.
    Here is where I asked:
    http://stackoverflow.com/questions/4133405/core-data-iphone-save-load-depending- on-date
    http://stackoverflow.com/questions/4177398/save-and-load-data-coredata
    I have unsuccessful so far and if anyone can help me here I would be ever so grateful and even more so if you would take a short time to take a peek at my project. You can email me at [email protected], its a fairly simple project and Im sure especially for you guys you could see what I am doing.
    Hope you can help me out.

    Core Data pretty much does away with the concepts of saving and loading. The data is just there. If you want a particular view of data, on a specific date, for examples, you create a predicate to pull only the matching data into a particular controller/UI control.

  • Core data refuses to work

    hi.
    I have a very simple model, it contains 1 entity with 4 attributes.
    I have created an ObjectController in IB, and bound it to my persistent document's object context.
    I follow this code (found in the core data documentation)to get a reference to the Object, and to set/get values:
    NSManagedObject *myDoc = [NSEntityDescription insertNewObjectForEntityForName:@"BKSketchDocMO" inManagedObjectContext:[dataSource managedObjectContext]];
    thePanX = [[myDoc valueForKey:@"docPanX"] floatValue];
    [myDoc setValue:[NSNumber numberWithFloat:[self bounds].size.width/2] forKey:@"docPanX"];
    now we come to the problem.
    its doesn't work. theres an entity. I can get a reference to it, and it ALWAYS has the default values. NOTHING i do changes the values, NOTHING i do gives me anything Except the default values.
    and since core data is basically a black box... I CAN"T DEBUG IT.
    can anyone, shed any light on anything that might explain why I can get the object, get values, but I cannot set values?
    signed,
    getting frustrated by the core data double-talk and general lack of any real, and useful documentation.
    Message was edited by: Edward Devlin1

    Hi kids, yet again I have answered my own question. in my application, I could not make my object graph self populate, and then when i did get it to populate programatically, I could not access the data.
    I have solved both problems. one was a conceptual problem, and the other was operator error building off of a conceptual problem.
    first, lets tackle why my object graph doesn't auto populate. in IB i made an Object controller, and I hooked it up to my entity. I told the controller to automatically prepare content. I had assumed that it meant that when my Object Context was instantiated, it would automatically create an instance of my referenced object. this is Not how core data works. Currently i am working under the impression that "automatically prepares content" mean that when an entity is instantiated, it will fill out the appropriate values, with the defaults you set up in your object model.
    so core data Does not actually instantiate anything for you. once I made this conceptual leap, I was still hazy on the implementation. I tried adding new entities upon initialization, but that tended to over-write entities opened from a saved document. in the end, I simply settled on making sure the entity existed when i tried to access its information. If it didn't exist I made one before trying to access it. in practice, this is a very slick and robust solution.
    now for problem #2... every time I tried to access my data, it is like it was zeroed out to the default settings.
    well, thats exactly what was happening. my entity was valid, I was making changes to it, and I was still getting the default values back. How was this happening? I didn't understand what i was doing.
    heres what I thought was happening. I thought I was making a new ManagedObject, and filling it with the values of the entity I was trying to access, then I got the values from that ManagedObject, and discarded it.
    What was really happening: If you look at my code, you'll see a method called : "insertNewObjectForEntityForName:" this is the method I THOUGHT was going to my ObjectContext, getting my entity and creating a ManagedObject from it for me to interface with. Clever coders will see the problem right away. Insert new Object? I was creating a new instance of my entity each time i Thought I was accessing the original. holy crap! of course I was only getting the default values... and sure I was able to make a change to the values, but the next time I tried to access them, I would just get a new entity, filled with default values!
    so InsertNewObject, was the wrong approach... what turned out to be the correct approach? heres why i was having such a bad time of this... NSDictionary, is roughly analogous to Core Data. I have alot of experience w/ NSDictionary, and so i expected a straight forward... give me an object based on this key method. I understood that i was going to have to work through a proxy, but I had assumed a little too much about how Core data works. its not like NSDictionary at all. it works much more like a search engine... you tell it where, and what to look for and it will bring you back a list of things that are kinda like what you're looking for.
    This is called a fetch request. Its a much more elaborate way to look for stuff than a simple objectForKey: method. its how you get your information from core data. Information comes back as an array of NSManagedObjects. The documentation made everything so much more difficult because it spoke of fetched values as something extra or added on to core data. Kids say it along w/ me.... fetch requests are how you get info from core data. repeat.

  • Core Data Issue

    I am creating a coredata sqlite database file in a mac app (using core data) and am attempting to use the same database and core data model in an ipad app.   I have copied all NSManagedObject files and the .xcdatamodeld directory from the mac app to the ios app.  Even though all files are identical I get "
    The model used to open the store is incompatible with the one used to create the store" when trying to read from the store in the app.  My question is what is actually being compared when this error is thrown?  It looks like it throws the error following SELECT Z_VERSION, Z_UUID, Z_PLIST FROM Z_METADATA.   What is a z_uuid?  Any ideas on how to debug this?   my error dump is below.
    2014-05-06 12:57:29.118 Genome[9055:60b] CoreData: sql: SELECT Z_VERSION, Z_UUID, Z_PLIST FROM Z_METADATA
    2014-05-06 12:57:29.119 Genome[9055:60b] CoreData: annotation: Disconnecting from sqlite database.
    2014-05-06 12:57:29.121 Genome[9055:60b] Unresolved error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x109527050 {metadata={
        NSPersistenceFrameworkVersion = 481;
        NSStoreModelVersionHashes =     {
            Annotation = <d4eb8bbc 528c6ac9 3cc1decb ca49790e 9933c09b faf47ec9 108fb9b4 b083e144>;
            Band = <14c5dda0 3db4c5c7 27952ce6 5421b597 6d97bed9 b6f225c7 0d956b54 2cfc8282>;
            Gene = <e70a2ed2 fa4c0c3e 1fb8eabc f0f1c26b 9dadb033 0c9198fe 9ba2393e c1a3f9c2>;
            Test = <051b8cd1 849daecf 7a94ac5a 87134d9b 1db8b51c 60bdca34 cb828268 01d6a73a>;
            User = <ebf4a8c8 7209296b 30bdf66c bd7a3dac afa9c8c5 d04f363f 14469686 ba458804>;
            Variant = <58231e33 52687ba7 053846d2 e8d27ed2 58ec690b 2fb09efc 303f299f 2592d6f5>;
        NSStoreModelVersionHashesVersion = 3;
        NSStoreModelVersionIdentifiers =     (
        NSStoreType = SQLite;
        NSStoreUUID = "9B3D312C-95C8-45E3-9F2F-2581E88403A8";
        "_NSAutoVacuumLevel" = 2;
    }, reason=The model used to open the store is incompatible with the one used to create the store}, {
        metadata =     {
            NSPersistenceFrameworkVersion = 481;
            NSStoreModelVersionHashes =         {
                Annotation = <d4eb8bbc 528c6ac9 3cc1decb ca49790e 9933c09b faf47ec9 108fb9b4 b083e144>;
                Band = <14c5dda0 3db4c5c7 27952ce6 5421b597 6d97bed9 b6f225c7 0d956b54 2cfc8282>;
                Gene = <e70a2ed2 fa4c0c3e 1fb8eabc f0f1c26b 9dadb033 0c9198fe 9ba2393e c1a3f9c2>;
                Test = <051b8cd1 849daecf 7a94ac5a 87134d9b 1db8b51c 60bdca34 cb828268 01d6a73a>;
                User = <ebf4a8c8 7209296b 30bdf66c bd7a3dac afa9c8c5 d04f363f 14469686 ba458804>;
                Variant = <58231e33 52687ba7 053846d2 e8d27ed2 58ec690b 2fb09efc 303f299f 2592d6f5>;
            NSStoreModelVersionHashesVersion = 3;
            NSStoreModelVersionIdentifiers =         (
            NSStoreType = SQLite;
            NSStoreUUID = "9B3D312C-95C8-45E3-9F2F-2581E88403A8";
            "_NSAutoVacuumLevel" = 2;
        reason = "The model used to open the store is incompatible with the one used to create the store";

    That is not it.  I acually had it working with Mavaricks and ios7 and then something changed.   I am wondering what exactly is being compared when the The model used to open the store is incompatible with the one used to create the store error is thrown.  It is obviously not the columns of the db and properties of the managed objects because they are identical.

  • Core Data Application Types

    Hi all,
    I'm working on an OSX app to be powered by Core Data (using SQLite) and I'm at the definition stage right now. I am struggling to find a definitive statement on what would be the right type of CD app to build. I have discounted the concept of building a foundation tool - I want to work with CD more directly. This leaves a few options on project set-up:
    + CD App
    + CD Doc Based App
    + CD Doc Based App with Spotlight
    The app is reasonably complex and has some possibly relevant requirements:
    1: Ability to have multiple save files e.g. File1.myapp, File2.myapp where you would load up your file and start working with the data (or create one of course). During the user session the user would add/edit data. On Add, the user will commit each set of entries once validated, and confirmed - I don't want it to auto save, the same goes for edits. Essentially, sheets etc will be in an "unsaved" state during usage, if that makes sense.
    2: The data entered drives multiple views and reports, used by the user. These reports will be rendered as PDFs and exportable to disk/email.
    3: Table views will be used on various views and a search box will be used to filter the output.
    So, the question is which is the most appropriate path, and why (or am I barking up the wrong tree entirely)?
    Hope that all makes sense, and thanks for your help,
    Chris

    @Chris S said:
    1: Ability to have multiple save files e.g. File1.myapp, File2.myapp
    Those sound a lot like docs to me....
    a search box will be used to filter the output
    sounds like spotlight to me...
    I think you'll be quite happy going for the "+ CD Doc Based App with Spotlight "
    this will just give you a better starting point, IMHO.... while the base code might not be exactly what you want, it gives you an example to work from (for docs and search) instead of working from nothing
    Sounds to me like you're right on target, Chris....

  • Core Data save error after delete

    I'm cross posting this from StackOverflow (http://stackoverflow.com/questions/1463382/core-data-save-error-after-delete)
    This question is probably a long shot. I can't figure out the errors I'm getting on my core data project when I save after I delete an entity. My .xcdatamodel can be seen at:
    http://jump.fm/BXRCG
    I have two main entities that I work with, an Outfit and an Article. I can create them with no problem but when I delete them I get the follow error log:
    for the Outfit:
    2009-09-22 20:17:37.771 itryiton[29027:20b] Operation could not be completed. (Cocoa error 1600.)
    2009-09-22 20:17:37.773 itryiton[29027:20b] {
    NSLocalizedDescription = "Operation could not be completed. (Cocoa error 1600.)";
    NSValidationErrorKey = outfitArticleViewProperties;
    NSValidationErrorObject = <Article: 0x12aa3c0> (entity: Article; id: 0x12b49a0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/Article/p1> ; data: {
    articleID = 2009-09-22 19:05:19 -0400;
    articleImage = 0x12b4de0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/ArticleImage/p1>;
    articleType = nil;
    attributeTitles = "(...not nil..)";
    color = nil;
    comment = nil;
    dateCreated = 2009-09-22 19:05:19 -0400;
    designer = nil;
    imageView = "(...not nil..)";
    location = "(...not nil..)";
    outfitArticleViewProperties = (
    0x12b50f0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/OutfitArticleViewProperties/ p1>
    ownesOrWants = 0;
    pattern = nil;
    price = nil;
    retailer = nil;
    thumbnail = "(...not nil..)";
    washRequirements = nil;
    wearableSeasons = nil;
    NSValidationErrorValue = {(
    <OutfitArticleViewProperties: 0x1215340> (entity: OutfitArticleViewProperties; id: 0x12b50f0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/OutfitArticleViewProperties/ p1> ; data: {
    article = 0x12b49a0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/Article/p1>;
    articleViewPropertiesID = nil;
    outfit = nil;
    touch = nil;
    view = "(...not nil..)";
    And if I delete an Article I get:
    2009-09-22 18:58:38.591 itryiton[28655:20b] Operation could not be completed. (Cocoa error 1560.)
    2009-09-22 18:58:38.593 itryiton[28655:20b] DetailedError: {
    NSLocalizedDescription = "Operation could not be completed. (Cocoa error 1600.)";
    NSValidationErrorKey = articleImage;
    NSValidationErrorObject = <Article: 0x12aa340> (entity: Article; id: 0x12b3f10 <x-coredata://05340FA6-B5DC-4646-A5B4-745C828C73C3/Article/p1> ; data: {
    articleID = 2009-09-22 18:58:26 -0400;
    articleImage = 0x12b4d00 <x-coredata://05340FA6-B5DC-4646-A5B4-745C828C73C3/ArticleImage/p1>;
    articleType = nil;
    attributeTitles = "(...not nil..)";
    color = nil;
    comment = nil;
    dateCreated = 2009-09-22 18:58:26 -0400;
    designer = nil;
    imageView = "(...not nil..)";
    location = "(...not nil..)";
    outfitArticleViewProperties = (
    0x12b5010 <x-coredata://05340FA6-B5DC-4646-A5B4-745C828C73C3/OutfitArticleViewProperties/ p1>
    ownesOrWants = 0;
    pattern = nil;
    price = nil;
    retailer = nil;
    thumbnail = "(...not nil..)";
    washRequirements = nil;
    wearableSeasons = nil;
    NSValidationErrorValue = <ArticleImage: 0x12ad600> (entity: ArticleImage; id: 0x12b4d00 <x-coredata://05340FA6-B5DC-4646-A5B4-745C828C73C3/ArticleImage/p1> ; data: {
    article = 0x12b3f10 <x-coredata://05340FA6-B5DC-4646-A5B4-745C828C73C3/Article/p1>;
    image = "(...not nil..)";
    A 1600 error is:
    NSValidationRelationshipDeniedDeleteError Error code to denote some relationship with delete rule NSDeleteRuleDeny is non-empty.
    Available in Mac OS X v10.4 and later.
    Declared in CoreDataErrors.h.
    But I can't see for the life of me which relationship would be preventing the delete. If some Core Data wizard can see the error of my ways, I would be humbled. But seriously, thank you!

    I'm cross posting this from StackOverflow (http://stackoverflow.com/questions/1463382/core-data-save-error-after-delete)
    This question is probably a long shot. I can't figure out the errors I'm getting on my core data project when I save after I delete an entity. My .xcdatamodel can be seen at:
    http://jump.fm/BXRCG
    I have two main entities that I work with, an Outfit and an Article. I can create them with no problem but when I delete them I get the follow error log:
    for the Outfit:
    2009-09-22 20:17:37.771 itryiton[29027:20b] Operation could not be completed. (Cocoa error 1600.)
    2009-09-22 20:17:37.773 itryiton[29027:20b] {
    NSLocalizedDescription = "Operation could not be completed. (Cocoa error 1600.)";
    NSValidationErrorKey = outfitArticleViewProperties;
    NSValidationErrorObject = <Article: 0x12aa3c0> (entity: Article; id: 0x12b49a0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/Article/p1> ; data: {
    articleID = 2009-09-22 19:05:19 -0400;
    articleImage = 0x12b4de0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/ArticleImage/p1>;
    articleType = nil;
    attributeTitles = "(...not nil..)";
    color = nil;
    comment = nil;
    dateCreated = 2009-09-22 19:05:19 -0400;
    designer = nil;
    imageView = "(...not nil..)";
    location = "(...not nil..)";
    outfitArticleViewProperties = (
    0x12b50f0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/OutfitArticleViewProperties/ p1>
    ownesOrWants = 0;
    pattern = nil;
    price = nil;
    retailer = nil;
    thumbnail = "(...not nil..)";
    washRequirements = nil;
    wearableSeasons = nil;
    NSValidationErrorValue = {(
    <OutfitArticleViewProperties: 0x1215340> (entity: OutfitArticleViewProperties; id: 0x12b50f0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/OutfitArticleViewProperties/ p1> ; data: {
    article = 0x12b49a0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/Article/p1>;
    articleViewPropertiesID = nil;
    outfit = nil;
    touch = nil;
    view = "(...not nil..)";
    And if I delete an Article I get:
    2009-09-22 18:58:38.591 itryiton[28655:20b] Operation could not be completed. (Cocoa error 1560.)
    2009-09-22 18:58:38.593 itryiton[28655:20b] DetailedError: {
    NSLocalizedDescription = "Operation could not be completed. (Cocoa error 1600.)";
    NSValidationErrorKey = articleImage;
    NSValidationErrorObject = <Article: 0x12aa340> (entity: Article; id: 0x12b3f10 <x-coredata://05340FA6-B5DC-4646-A5B4-745C828C73C3/Article/p1> ; data: {
    articleID = 2009-09-22 18:58:26 -0400;
    articleImage = 0x12b4d00 <x-coredata://05340FA6-B5DC-4646-A5B4-745C828C73C3/ArticleImage/p1>;
    articleType = nil;
    attributeTitles = "(...not nil..)";
    color = nil;
    comment = nil;
    dateCreated = 2009-09-22 18:58:26 -0400;
    designer = nil;
    imageView = "(...not nil..)";
    location = "(...not nil..)";
    outfitArticleViewProperties = (
    0x12b5010 <x-coredata://05340FA6-B5DC-4646-A5B4-745C828C73C3/OutfitArticleViewProperties/ p1>
    ownesOrWants = 0;
    pattern = nil;
    price = nil;
    retailer = nil;
    thumbnail = "(...not nil..)";
    washRequirements = nil;
    wearableSeasons = nil;
    NSValidationErrorValue = <ArticleImage: 0x12ad600> (entity: ArticleImage; id: 0x12b4d00 <x-coredata://05340FA6-B5DC-4646-A5B4-745C828C73C3/ArticleImage/p1> ; data: {
    article = 0x12b3f10 <x-coredata://05340FA6-B5DC-4646-A5B4-745C828C73C3/Article/p1>;
    image = "(...not nil..)";
    A 1600 error is:
    NSValidationRelationshipDeniedDeleteError Error code to denote some relationship with delete rule NSDeleteRuleDeny is non-empty.
    Available in Mac OS X v10.4 and later.
    Declared in CoreDataErrors.h.
    But I can't see for the life of me which relationship would be preventing the delete. If some Core Data wizard can see the error of my ways, I would be humbled. But seriously, thank you!

  • Core Data & PostgreSQL?

    Is it yet possible to create Core Data-based Cocoa apps that use PostgreSQL instead of SQLite as the RDB backend?
    I've seen some old forum posts that suggests that this would be possible in "the future" (then). Is this capability any closer to reality? If not, does anyone know if the problem is a technical one, or a licensing one, or something else?
    And more generally, has Apple made any "official" statements on these questions?
    Thanks!
    G

    It is unlikely to be a licensing issue, since PostgreSQL has a really free license.

  • Core data details

    I have to use core data in my new application,and i hav to send my data to server through http post ,m a new comer to i Phone devlopment world.I M having no idea. is any who can help me out,code would b appreciated
    Thanx in advance

    Hi There, This forum isn't really for programming questions, it's more for end-user support.
    There are also developer forums and help in Apple Dev Connection
    Hope this helps

  • Core Data: Get Managed Object by unique part of the objectID

    In my Core Data application, I need to get the pointers to different managed objects whose CoreData objectIDs end with the number I provide. e.g.:
    Get the Person object whose objectID ends with unique number 317. The whole ID is:
    <x-coredata://A3EDF6C1-229D-4658-A04E-598ADF1C749A/Person/p317>
    or I need to get Department object, which ends with 5; again full ID is:
    <x-coredata://A3EDF6C1-229D-4658-A04E-598ADF1C749A/Department/p5>
    These numbers are actually primary keys in the SQLite database's tables and I can see them if I open the database directly with sqlite3, and I can of course select the records using SQL query;
    *but I can not figure out how to get these objects using CoreData. I guess I should create the NSPredicate for the fetch request; but I don't know how to write the predicate which will give me the exact object based on the unique part of the objectID*
    As I understand, objectIDs are not object's "normal" attributes.
    Please help. Thanks in advance.

    etresoft wrote:
    DavidMan wrote:
    *but I can not figure out how to get these objects using CoreData. I guess I should create the NSPredicate for the fetch request; but I don't know how to write the predicate which will give me the exact object based on the unique part of the objectID*
    I think you are supposed to consider the entire ID to be unique. You can retrieve the associated object using "objectWithID:" from NSManagedObjectContext.
    The problem is that I am parsing the text from another application and I have only the "unique part" at hand and not the whole objectID. So, I need to cope with that.
    What I see is that the IDs of every entity start with the same text, e.g. here are the IDs of two different entities:
    <x-coredata://A3EDF6C1-229D-4658-A04E-598ADF1C749A/Person/p317>
    <x-coredata://A3EDF6C1-229D-4658-A04E-598ADF1C749A/Department/p5>
    As you see, the difference is only in the end, after the entity names "Paper" and "Department". But this is my case and I am not completely sure that this will hold true for EVERY future installation on any system for every entity.
    *Question: will the part like <x-coredata://A3EDF6C1-229D-4658-A04E-598ADF1C749A be constant for the particular installation, for every entity/object?*
    If YES, then I will:
    - after getting any/first object, extract the non-unique part, i.e. <x-coredata...749A which is the same for every object in this particular installation on this particular computer
    - get the unique part, i.e. /Person/p317, /Person/p23, /Department/p5 etc.
    - synthesize the "real ID" by appending these two strings
    - ask managedObjectContext to return the object with this ID
    - continue with the acquired object
    How does it sound? Will this work on other computers?
    P.S. FYI: the coredata of this program has only one store i.e. all the data are stored in single sqlite file.

  • IPhone core data - fetched managed objects not being autoreleased on device (fine on simulator)

    I'm currently struggling with a core data issue with my app that defies (my) logic. I'm sure I'm doing something wrong but can't see what. I am doing a basic executeFetchRequest on my core data entity, but the array of managed objects returned never seems to be released ONLY when I run it on the iPhone, under the simulator it works exactly as expected. This is despite using an NSAutoreleasePool to ensure the memory footprint is minimised. I have also checked with Instruments and there are no leaks, just ever increasing allocations of memory (by '[NSManagedObject(_PFDynamicAccessorsAndPropertySupport) allocWithEntity:]'). In my actual app this eventually leads to a didReceiveMemoryWarning call. I have produced a minimal program that reproduces the problem below. I have tried various things such as faulting all the objects before draining the pool, but with no joy. If I provide an NSError pointer to the fetch no error is returned. There are no background threads running.
    +(natural_t) get_free_memory {
        mach_port_t host_port;
        mach_msg_type_number_t host_size;
        vm_size_t pagesize;
        host_port = mach_host_self();
        host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
        host_page_size(host_port, &pagesize);
        vm_statistics_data_t vm_stat;
        if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) {
            NSLog(@"Failed to fetch vm statistics");
            return 0;
        /* Stats in bytes */
        natural_t mem_free = vm_stat.free_count * pagesize;
        return mem_free;
    - (void)viewDidLoad
        [super viewDidLoad];
        // Set up the edit and add buttons.
        self.navigationItem.leftBarButtonItem = self.editButtonItem;
        UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject)];
        self.navigationItem.rightBarButtonItem = addButton;
        [addButton release];
        // Obtain the Managed Object Context
        NSManagedObjectContext *context = [(id)[[UIApplication sharedApplication] delegate] managedObjectContext];
        // Check the free memory before we start
        NSLog(@"INITIAL FREEMEM: %d", [RootViewController get_free_memory]);
        // Loop around a few times
        for(int i=0; i<20; i++) {
            // Create an autorelease pool just for this loop
            NSAutoreleasePool *looppool = [[NSAutoreleasePool alloc] init];
            // Check the free memory each time around the loop
            NSLog(@"FREEMEM: %d", [RootViewController get_free_memory]);
            // Create a minimal request
            NSEntityDescription *entityDescription = [NSEntityDescription                                                 
                                                  entityForName:@"TestEntity" inManagedObjectContext:context];
            // 'request' released after fetch to minimise use of autorelease pool       
            NSFetchRequest *request = [[NSFetchRequest alloc] init];
            [request setEntity:entityDescription];
            // Perform the fetch
            NSArray *array = [context executeFetchRequest:request error:nil];       
            [request release];
            // Drain the pool - should release the fetched managed objects?
            [looppool drain];
        // Check the free menory at the end
        NSLog(@"FINAL FREEMEM: %d", [RootViewController get_free_memory]);
    When I run the above on the simulator I get the following output (which looks reasonable to me):
    2011-06-06 09:50:28.123 renniksoft[937:207] INITIAL FREEMEM: 14782464
    2011-06-06 09:50:28.128 renniksoft[937:207] FREEMEM: 14807040
    2011-06-06 09:50:28.135 renniksoft[937:207] FREEMEM: 14831616
    2011-06-06 09:50:28.139 renniksoft[937:207] FREEMEM: 14852096
    2011-06-06 09:50:28.142 renniksoft[937:207] FREEMEM: 14872576
    2011-06-06 09:50:28.146 renniksoft[937:207] FREEMEM: 14897152
    2011-06-06 09:50:28.149 renniksoft[937:207] FREEMEM: 14917632
    2011-06-06 09:50:28.153 renniksoft[937:207] FREEMEM: 14938112
    2011-06-06 09:50:28.158 renniksoft[937:207] FREEMEM: 14962688
    2011-06-06 09:50:28.161 renniksoft[937:207] FREEMEM: 14983168
    2011-06-06 09:50:28.165 renniksoft[937:207] FREEMEM: 14741504
    2011-06-06 09:50:28.168 renniksoft[937:207] FREEMEM: 14770176
    2011-06-06 09:50:28.174 renniksoft[937:207] FREEMEM: 14790656
    2011-06-06 09:50:28.177 renniksoft[937:207] FREEMEM: 14811136
    2011-06-06 09:50:28.182 renniksoft[937:207] FREEMEM: 14831616
    2011-06-06 09:50:28.186 renniksoft[937:207] FREEMEM: 14589952
    2011-06-06 09:50:28.189 renniksoft[937:207] FREEMEM: 14610432
    2011-06-06 09:50:28.192 renniksoft[937:207] FREEMEM: 14630912
    2011-06-06 09:50:28.194 renniksoft[937:207] FREEMEM: 14651392
    2011-06-06 09:50:28.197 renniksoft[937:207] FREEMEM: 14671872
    2011-06-06 09:50:28.200 renniksoft[937:207] FREEMEM: 14692352
    2011-06-06 09:50:28.203 renniksoft[937:207] FINAL FREEMEM: 14716928
    However, when I run it on an actual iPhone 4 (4.3.3) I get the following result:
    2011-06-06 09:55:54.341 renniksoft[4727:707] INITIAL FREEMEM: 267927552
    2011-06-06 09:55:54.348 renniksoft[4727:707] FREEMEM: 267952128
    2011-06-06 09:55:54.702 renniksoft[4727:707] FREEMEM: 265818112
    2011-06-06 09:55:55.214 renniksoft[4727:707] FREEMEM: 265355264
    2011-06-06 09:55:55.714 renniksoft[4727:707] FREEMEM: 264892416
    2011-06-06 09:55:56.215 renniksoft[4727:707] FREEMEM: 264441856
    2011-06-06 09:55:56.713 renniksoft[4727:707] FREEMEM: 263979008
    2011-06-06 09:55:57.226 renniksoft[4727:707] FREEMEM: 264089600
    2011-06-06 09:55:57.721 renniksoft[4727:707] FREEMEM: 263630848
    2011-06-06 09:55:58.226 renniksoft[4727:707] FREEMEM: 263168000
    2011-06-06 09:55:58.726 renniksoft[4727:707] FREEMEM: 262705152
    2011-06-06 09:55:59.242 renniksoft[4727:707] FREEMEM: 262852608
    2011-06-06 09:55:59.737 renniksoft[4727:707] FREEMEM: 262389760
    2011-06-06 09:56:00.243 renniksoft[4727:707] FREEMEM: 261931008
    2011-06-06 09:56:00.751 renniksoft[4727:707] FREEMEM: 261992448
    2011-06-06 09:56:01.280 renniksoft[4727:707] FREEMEM: 261574656
    2011-06-06 09:56:01.774 renniksoft[4727:707] FREEMEM: 261148672
    2011-06-06 09:56:02.290 renniksoft[4727:707] FREEMEM: 260755456
    2011-06-06 09:56:02.820 renniksoft[4727:707] FREEMEM: 260837376
    2011-06-06 09:56:03.334 renniksoft[4727:707] FREEMEM: 260395008
    2011-06-06 09:56:03.825 renniksoft[4727:707] FREEMEM: 259932160
    2011-06-06 09:56:04.346 renniksoft[4727:707] FINAL FREEMEM: 259555328
    The amount of free memory reduces each time round the loop in proportion to the managed objects I fetch e.g. if I fetch twice as many objects then the free memory reduces twice as quickly - so I'm pretty confident it is the managed objects that are not being released. Note that the entities that are being fetched are very basic, just two attributes, a string and a 16 bit integer. There are 1000 of them being fetched in the examples above. The code I used to generate them is as follows:
    // Create test entities
    for(int i=0; i<1000; i++) {
        id entity = [NSEntityDescription insertNewObjectForEntityForName:@"TestEntity" inManagedObjectContext:context];
        [entity setValue:[NSString stringWithFormat:@"%d",i] forKey:@"name"];
        [entity setValue:[NSNumber numberWithInt:i] forKey:@"value"];
    if (![context save:nil]) {
        NSLog(@"Couldn't save");
    If anyone can explain to me what is going on I'd be very grateful! This issue is the only only one holding up the release of my app. It works beautifully on the simulator!!
    Please let me know if there's any more info I can supply.

    Update: I modified the above code so that the fetch (and looppool etc.) take place when a timer fires. This means that the fetches aren't blocked in viewDidLoad.
    The result of this is that the issue happens exactly as before, but the applicationDidReceiveMemoryWarning is fired as expected:
    2011-06-08 09:54:21.024 renniksoft[5993:707] FREEMEM: 6131712
    2011-06-08 09:54:22.922 renniksoft[5993:707] Received memory warning. Level=2
    2011-06-08 09:54:22.926 renniksoft[5993:707] applicationDidReceiveMemoryWarning
    2011-06-08 09:54:22.929 renniksoft[5993:707] FREEMEM: 5615616
    2011-06-08 09:54:22.932 renniksoft[5993:707] didReceiveMemoryWarning
    2011-06-08 09:54:22.935 renniksoft[5993:707] FREEMEM: 5656576

Maybe you are looking for

  • Oracle ifs and BEA weblogic

    Oracle ifs and BEA weblogic We have one application server with weblogic and and ifs 1.0.9 , and one db server with Oracle 8.1.7. with the following configuration: Web server appl server with weblogic 6.0 and ifs 1.1.9 Oracle 8i Enterprise with inter

  • Crystal Report Viewer on Client Machine

    Hi all,            I am new to Crystal Reports. I want Open the crystal Report from SAP Interprise Portal. I want to know the Crytal Report viewer needs to be installed on client machine or without that also we can show the report. Thanks for your su

  • Dreamweaver Accordian not working in IE6

    I've added the Spry Accordian function to a page but it only works correctly in Safari 2. On opening the page in both Firefox and IE 6 only the first level displays, the second and third level are invisible. Only after clicking in the general area wh

  • Lumia 520 music player gets paused automatically!

    I got this problem from today morning. Whenever I play any music file on my speakers it gets paused automatically after a few seconds of playing and when I play it again it gets paused again. I have been facing this problem only while playing music o

  • Regd.Promise to Pay - Notes POID

    Hi FSCM Gurus, This is related to Promise to Pay Case, Notes Field. Each case id has one notes field in which any Customer Notes can be stored. To save this notes, notes GUID is required. Could you please let me know where I can get this, Notes  GUID