{"id":1498,"date":"2018-03-01T17:43:47","date_gmt":"2018-03-01T17:43:47","guid":{"rendered":"https:\/\/rowewp.mydrobo.com\/?p=1498"},"modified":"2022-12-15T06:46:20","modified_gmt":"2022-12-15T11:46:20","slug":"debugging-core-data","status":"publish","type":"post","link":"https:\/\/michaelrowe01.com\/index.php\/blog\/debugging-core-data\/","title":{"rendered":"Debugging Core Data"},"content":{"rendered":"<p>One of the reasons I&#8217;ve toyed with the new app for so long (the idea is about 5 years old), has been that I am struggling to learn Core Data.  Not only that, but I&#8217;ve been dealing with a ton of day job activities, etc.   So I am finally getting this app started.  The basic idea behind the application is a header-&gt;detail line database challenge, back when I did DB programming this would have been called an invoice problem.  In this case, we have from 0 to infinite headers (each one a unique record), and each header can have from 0 to infinite detailed records.<\/p>\n<p>In Core data you would define your entities with Header having a one to many relationship to Detail.  And that relationship would be optional, since you could have 0 detailed entities.  Right now the application does a good job of showing you a list of the headers, and allowing you to  add new headers.  My early builds (the ones were I didn&#8217;t define the detail records) even let you go back and do a detail view of the headers.<\/p>\n<p>Now when I go to the header views, it crashes while trying to give you a UITableView of the detailed records.  Obviously I am not handling Detail records correctly.  I&#8217;ve been told that these records are an NSSet and should be converted to an Array for UITableView handling.  So my current guess is I am not handling an empty Array correctly. I am guessing I need to set it to NIL in the ViewController and then assign data to it in the TableView functions. (I will try that this weekend).<\/p>\n<p>My second crash is when I try to allow a user to delete the Header records.  I was able to do this originally, so somehow in my refactoring of the app to add the detail records, I must have screwed something up.  I hope to fix this one quickly.<\/p>\n<p>Now the reason I called this post &#8220;Debugging Core Data&#8221; is because the crashes don&#8217;t seem to provide me with a lot of insights, in to what the crash really is, but I find if I try and explain a programming problem I have to someone, I tend to work it out.  Let&#8217;s hope this worked!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the reasons I&#8217;ve toyed with the new app for so long (the idea is about 5 years old), has been that I am struggling to learn Core Data. Not only that, but I&#8217;ve been dealing with a ton of day job activities, etc. So I am finally getting this app started. The basic [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"hide_page_title":"","_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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2],"tags":[24,97,111,207,217,326],"class_list":["post-1498","post","type-post","status-publish","format-standard","hentry","category-blog","tag-app","tag-core-data","tag-debugging","tag-ideas","tag-ios","tag-programming"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2aMa8-oa","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/posts\/1498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/comments?post=1498"}],"version-history":[{"count":1,"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/posts\/1498\/revisions"}],"predecessor-version":[{"id":2734,"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/posts\/1498\/revisions\/2734"}],"wp:attachment":[{"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/media?parent=1498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/categories?post=1498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/tags?post=1498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}