The main problem with saving data: it is not possible to update a transformable attribute (NSArray)

I have a strange problem in a Core Data application.

I have three objects in my application, but today I found a problem with one of them. My problematic entity is called Invoiceand has many attributes, including Products. It encoded an NSArray from NSDictionaries (default is NSValueTransformer).

Everything works fine - I create my account, his client, his products, etc. Everything is working.

But , when I select my account from the list, and then try to edit its products and click the "Save" button, my save only works until my application is complete.

The problem is only in my array Products- the rest (for example, payment date, customer, etc.) are saved.


What am I doing

I pass my Invoiceobject through

NSManagedObject *inv = [self.fetchedResultsController objectAtIndexPath:indexPath];
invoiceEditor.invoice = inv;

And save my data (in my InvoiceEditorVC):

[self.invoice setValue:client forKey:@"Client"] // NSDictionary;
[self.invoice setValue:products forKey:@"Products"] // NSArray of NSDictionaries;
[self.invoice setValue:pmDate forKey:@"PaymentDate"] // NSDate;
// other attributes
NSManagedObjectContext *context = self.invoice.managedObjectContext;
NSError *error = nil;
if (![context save:&error]) {
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    abort();
}

All things are saved until completion: customer, products, dates. But only the products "reboot" after completion.

Is anyone

+5
source share
2 answers

Just found a problem. From the Guide to the implementation of the model object :

, , NSArray NSMutableArray, get accessor , .

products NSMutableArray. , products ( ). .:) ...

+4

, . , , CoreData .

CoreData .

0

All Articles