{"id":64,"date":"2012-01-28T17:13:53","date_gmt":"2012-01-28T17:13:53","guid":{"rendered":"http:\/\/ootips.org\/yonat\/?p=64"},"modified":"2016-04-17T07:32:20","modified_gmt":"2016-04-17T07:32:20","slug":"uiimage-in-coredata","status":"publish","type":"post","link":"https:\/\/ootips.org\/yonat\/uiimage-in-coredata\/","title":{"rendered":"Store UIImage in CoreData Without Writing Any Code"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-66\" title=\"NSUnarchiveFromDataTransformerName\" src=\"https:\/\/ootips.org\/yonat\/wp-content\/uploads\/2012\/01\/NSUnarchiveFromDataTransformerName.png\" alt=\"\" width=\"264\" height=\"257\" \/>There is an easy but little known way to store many kinds of UIKit objects in CoreData without writing any code. It works for UIImage, UIColor, UIBezierPath, MKPlaceMark, NSDate, and any other class that conforms to the <strong>NSCoding<\/strong> protocol.<\/p>\n<p>What you need to do is set the attribute type to <strong>Transformable<\/strong>.<\/p>\n<p>That&#8217;s it!<\/p>\n<p>Now can set UIImage objects directly into your NSManagedObject objects:<\/p>\n<pre class=\"lang:objc decode:true \">\r\nperson.thumbnailImage = [UIImage imageNamed:@\"defaultPortrait\"];\r\nanImageView.image = person.thumbnailImage;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There is an easy but little known way to store many kinds of UIKit objects in CoreData without writing any code. It works for UIImage, UIColor, UIBezierPath, MKPlaceMark, NSDate, and any other class that conforms to the NSCoding protocol. What &hellip; <a href=\"https:\/\/ootips.org\/yonat\/uiimage-in-coredata\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[1],"tags":[18,8,7,6,13],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-cocoa","tag-coredata","tag-ios","tag-iphone","tag-objective-c"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2aEUP-12","_links":{"self":[{"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":13,"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":257,"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/posts\/64\/revisions\/257"}],"wp:attachment":[{"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}