Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS Core data relationship faults
    primarykey
    data
    text
    <p>I have a core data model that has 3 entities. Driver, Manifest and Jobs.</p> <p>Each Manifest has one driver, each Driver has multiple Manifests, each Manifest can have one or more Jobs and each Job refers to one Manifest.</p> <p>When I build up the objects like so</p> <pre><code>//Loop through all the Manifests for the driver for (SDZManifest *manifest in allData) { //Create an new instance of manifest in core data Manifest *newManifest = (Manifest*)[[SKCoreDataManager sharedInstance] insertObjectforEntity:kEntity_Manifest]; // *** // Set the data for this manifest // *** [newManifest setDriverID:[NSNumber numberWithInt:[manifest DriverId]]]; [newManifest setManifestID:[manifest ManifestId]]; [newManifest setManifestRef:[manifest ManifestRef]]; [newManifest setSupplierID:[NSNumber numberWithInt:[manifest SupplierId]]]; [newManifest setTruckID:[NSNumber numberWithInt:[manifest TruckId]]]; //Get all the jobs for the manifest NSArray *allJobsForManifest = [manifest Jobs]; NSMutableArray *formattedJobsForManifest = [NSMutableArray array]; //Loop through all the Jobs for this manifiest for (SDZJob *job in allJobsForManifest) { //Set the returned data into a Job object Job *newJob = (Job*)[[SKCoreDataManager sharedInstance] insertObjectforEntity:kEntity_Job]; [newJob setInstructions:[job Instructions]]; [newJob setDateCreated:[job DateCreated]]; [newJob setCreatedBy:[job CreatedBy]]; [newJob setIsLive:[NSNumber numberWithBool:[job IsLive]]]; [newJob setCollectionSequence:[NSNumber numberWithInt:[job CollectionSequence]]]; [newJob setPlannedDeliveryDate:[job PlannedDeliveryDate]]; [newJob setPlannedCollectionDate:[job PlannedCollectionDate]]; [newJob setCustomerRef:[job CustomerRef]]; [newJob setCustomerName:[job CustomerName]]; // *** // Collection address // *** //Break down the address SDZAddress *collectionAddress = [job CollectionAddress]; [newJob setCollectionAddressID:[NSNumber numberWithInt:[collectionAddress Id]]]; [newJob setCollectionAddressLine1:[collectionAddress line1]]; [newJob setCollectionAddressLine2:[collectionAddress line2]]; [newJob setCollectionAddressLine3:[collectionAddress line3]]; [newJob setCollectionAddressCity:[collectionAddress city]]; [newJob setCollectionAddressCounty:[collectionAddress county]]; [newJob setCollectionAddressCountry:[collectionAddress country]]; [newJob setCollectionAddressPostcode:[collectionAddress postcode]]; //Get the lat and lng of the collection address SDZGeoLocation *collectionAddressLatLng = [collectionAddress Geocode]; [newJob setCollectionAddressLat:[collectionAddressLatLng Lat]]; [newJob setCollectionAddressLng:[collectionAddressLatLng Lng]]; // *** // Delivery address // *** //Break down the address SDZAddress *deliveryAddress = [job DeliveryAddress]; [newJob setDeliveryAddressID:[NSNumber numberWithInt:[deliveryAddress Id]]]; [newJob setDeliveryAddressLine1:[deliveryAddress line1]]; [newJob setDeliveryAddressLine2:[deliveryAddress line2]]; [newJob setDeliveryAddressLine3:[deliveryAddress line3]]; [newJob setDeliveryAddressCity:[deliveryAddress city]]; [newJob setDeliveryAddressCounty:[deliveryAddress county]]; [newJob setDeliveryAddressCountry:[deliveryAddress country]]; [newJob setDeliveryAddressPostcode:[deliveryAddress postcode]]; //Get the lat and lng of the collection address SDZGeoLocation *deliveryAddressLatLng = [deliveryAddress Geocode]; [newJob setDeliveryAddressLat:[deliveryAddressLatLng Lat]]; [newJob setDeliveryAddressLng:[deliveryAddressLatLng Lng]]; [formattedJobsForManifest addObject:newJob]; NSLog(@"\n\n-- NEW JOB --\n%@\n\n", newJob); } //Show all Jobs for this manifest NSLog(@"\n\n-- JOBS FOR MANIFEST --\n%@\n\n", formattedJobsForManifest); } </code></pre> <p>I then save that Manifest object to core data.</p> <p>When they click on the table view cell I get the object from an array of manifests and pass it to another view. When I log the passed manifest it loggs :</p> <pre><code>-- PASSED MANIFEST -- &lt;Manifest: 0xe59d540&gt; (entity: Manifest; id: 0xe59c3e0 &lt;x-coredata://9F572794-745F-4E43-B4D0-9EC3506EA6E4/Manifest/p5&gt; ; data: { driver = nil; driverID = 1; jobs = "&lt;relationship fault: 0x7b3d290 'jobs'&gt;"; manifestID = "f705c777-9455-4792-bd84-2deada410dab"; manifestRef = 001; supplierID = 2; truckID = 8; }) </code></pre> <p>When I log <code>NSLog(@"\n\n-- PASSED MANIFEST JOBS --\n%@\n\n", [passedManifest jobs]);</code> the result is</p> <pre><code>-- PASSED MANIFEST JOBS -- Relationship 'jobs' fault on managed object (0xe59d540) &lt;Manifest: 0xe59d540&gt; (entity: Manifest; id: 0xe59c3e0 &lt;x-coredata://9F572794-745F-4E43-B4D0-9EC3506EA6E4/Manifest/p5&gt; ; data: { driver = nil; driverID = 1; jobs = "&lt;relationship fault: 0x7b3d290 'jobs'&gt;"; manifestID = "f705c777-9455-4792-bd84-2deada410dab"; manifestRef = 001; supplierID = 2; truckID = 8; }) </code></pre> <p>Why is it saying <strong>Relationship 'jobs' fault on managed object (0xe59d540)</strong>?</p> <p>When I <code>NSLog(@"\n\n-- JOB COUNT --\n%u\n\n", [[passedManifest jobs] count]);</code> it returns <strong>0</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload