iCloud Dashboard: How to view Coredata transformable fields? - core-data

My app uses CoreData & CloudKit mirroring. Some entities have attributes of type Transformable, corresponding e.g. to a property #NSManaged var names: Set<String>?.
In the xcdatamodeld file, the transformer is set to NSSecureUnarchiveFromDataTransformer.
Such fields are converted to NSData, and in the iCloud Dashboard they have type Bytes, i.e. the value is binary and cannot be interpreted. However, such fields can be downloaded.
Question: How can I view the content of such downloaded fields to check if it is correct?

Related

How do we eager fetch content fields from the Orchard CMS Queries user interface

When using the Orchard UI to create queries, how do we eager fetch fields? For instance, we have a content type that has an input field, link field, media library picker field, date time field, and text field. None of these fields are terribly complex. How do we eager load fields from the UI? I've looked at the Eager Load filter, and based on intuition, have considered eager loading the FieldIndexPartRecord.
You don't need to: fields are stored in the Infoset, which is a XML data blob stored on the content item's record. Therefore, it is always eager-fetched. Do you have profile data indicating otherwise?

ADO.Net Entity Data Model does not decorate fields with required attribute

I am trying to reverse engineer a SQL Server database to an Entity Framework Data Model (version 6.0). The classes are generated fine, but required fields are not decorated as such. As a result the validation is not working (in an MVC 5 web application).
Is there a way to make the model generate these attributes automatically or do I have to manually write meta data classes for all my entities?
Speaking to your question, What are your assumptions for required fields? Do you mean non-nullable?
EF should make any field that is marked as not null as either a non-nullable value type (int, decimal, bool, etc.) or it will make fields required via xml validation. EF doesn't typically add attributes.
MVC will automatically make any value types required, no attribute is required. For strings or other possible nullable types, then you will either need "buddy classes" to add the attributes you need, or you use view models.

Store image in core data

I want to store image for every employee while updating their records. How can I do that?
I have a dictionary storing name, id and department of employees. Now i want the image to be saved together.
Core Data supports the "Binary Data" type - When you define a model with a Binary Data field, it creates your model class with an NSData field. You can move an image into the NSData field, and CoreData will save it for you.
You can then use UIImage initWithData: to load the image from the NSData field.
Hope this helps !
For strore image as CoreDate attribute need:
Add transformable attribute and set transformer with own class
Implement ImageToDataTransformer
See here for an example http://www.iphonedevsdk.com/forum/181656-post3.html

Is it possible to retain custom attributes in a class instance after deserialization?

I'm trying to build a custom HTML helper for MVC.NET that would allow me to render object entities (Model Objects) as HTML forms. So I decided to do it using custom attributes such as html input type, readonly flag, css classes, etc. Similar in a way to LINQ Mapping attributes that set database related bindings for Table and Column. So I did write a custom attribute class, applied it to the same entities that I store in the database, but when I retrieve an entity class from a database to display in a View, all of my custom attributes are gone. Is there a way to retain my custom attributes, AFTER they come back from a database?

Updates to NSDictionary attribute in CoreData not saving

I have created an Entity in CoreData that includes a Transformable attribute type implemented as an NSDictionary. The NSDictionary attribute only contains values of a custom class. The properties of the custom class are all of type NSString. The custom class complies with NSCoding implementing:
-(void)encodeWithCoder:(NSCoder*)coder;
-(id)initWithCoder:(NSCoder *)coder
When saving the Entity for the first time all attributes including the Transformable (NSDictionary) type are properly saved in the DB. When the same Entity is fetched from the DB and updated (including the Transformable attribute) it seems to be updated properly. However, when the app is closed and then reopened fetching the Entity does not show the updated Transformable attribute-type though the rest of the attributes of type NSDate and NSString are up-to-date. The Transformable attribute is the original saved value not the updated value.
Is this a problem with KVO or am I missing something else when trying to save an NSDictionary filled with a custom class to CoreData?
Are you setting the value back into the NSManagedObject? The NSManagedObject will not watch for changes to the transformable object. You need to call the appropriate setter before saving.
I ran into the same problem and ended up switching to NSDictionary as transformable attribute instead of NSMutableDictionary. Just fetch the NSDictionary as mutableCopy, work on that, put the end result into an NSDictionary and reinsert that into the managedObject.
Did the trick for me and i havent found another solution yet.

Resources