4

Description

Hello! So i am saving several strings of user inputed data into CoreData using a handful of NSManagedObject subclasses. Since the application is actually a machine inspection, it is necessary to print/email the customer entered information out in a somewhat structured format. Below you will find pictures/examples of how i am saving the data. Please be kind to me, for it is my birthday <3

Code examples

Below is an example of how i am saving the information. In the example, the CoreData entity is "CrawlerThree" and the data is crawlerDistance.

@IBAction func save(_ sender: AnyObject) {
    let appDel:AppDelegate = (UIApplication.shared().delegate as! AppDelegate)
    let context:NSManagedObjectContext = appDel.managedObjectContext
    let entity1 = NSEntityDescription.insertNewObject(forEntityName: "CrawlerThree", into:context) as NSManagedObject as! CrawlerThree
    entity1.crawlerDistance = distance.text

}

The rest of the saves are almost identical to this, with varying entities and data, all of which are strings. I know this is a rather vague post, but i really do need to know what i need to use to format this information. It is worth noting that i already know how to actually retrieve the string's from CoreData, I am simply ignorant on how to actually process them to some other form.

The Simplest solution will be the best solution for my problem! Thanks in advance!

gavsta707
  • 365
  • 3
  • 16

1 Answers1

1

I would divide the problem into two.

  1. Output from Core Data to screen
  2. Export as PDF

It sounds as if you know how to get your strings from Core Data already, so you just have to display them in a suitable way.

Fortunately whatever you use on screen: UIView, UITableView etc. can be saved as a PDF using e.g. the (Swift) answer to How to Convert UIView to PDF within iOS?

Community
  • 1
  • 1
DDP
  • 2,463
  • 1
  • 26
  • 28