When I try to get a string value from an NSManagedObject, I get this
<Entity: 0x1e043140> (entity: Entity; id: 0x1e041c30 <x-coredata://8F48C331-B879-47B4-B257-4802A13ED12C/Entity/p4> ; data: {
number = "<UITextField: 0x1d8b7cc0; frame = (159 183; 161 30); text = 'test'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x1d8b3c10>; layer = <CALayer: 0x1d892a30>> : ";
})
how do I get the string from this (it’s text = ‘test’;)
i get the object using this
NSString *rowValue = [self.fetchedResultsController objectAtIndexPath:indexPath];
ok, well the nsmanaged object is this and sets a uitableview cell to its string
NSManagedObject *object = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = [[object valueForKey:@"number"] description];
The reason it’s showing what it does is because, as you can see, I am getting it’s description. I can’t find a property that would return the text value, so does anyone know how? Thanks.
I assume that the error already occurs when you store a value in the managed object. Perhaps you do something like
instead of storing the text field’s text contents:
UPDATE: As you write in a comment, the managed object values are stored as
But the
%@format for aUITextFielditself is expanded to the text fields description, not the text contents. Therefore thestringalready looks likeand this string is stored as “number” attribute in the managed object. You should use the following code instead:
Note that you have to delete the old database when testing this to get rid of the already existing wrong entries.