I am trying to fetch a core data string from binary data. I am trying to use func getText to do this but I am getting an error stating Type of expression is ambiguous without more context at let imageData = Person[textNo].name!. I also have the singleton. I would like to print ideally the first saved name in core in the debug section. The data saves fine.
**extension** Person {
**@nonobjc** **public** **class** **func** fetchRequest() -> NSFetchRequest<Person> {
**return** NSFetchRequest<Person>(entityName: "Person")
}
**@NSManaged** **public** **var** name: String?
**@NSManaged** **public** **var** ssn: Int16
}
class ViewController: UIViewController {
func getText(textNo:Int) {
// first check the array bounds
let info = helpText.shareInstance.fetchText()
if info.count > textNo {
if let imageData = Person[textNo].name!
{
print(imageData)
} else {
// no data
print("data is empty Textss")
}
} else {
// image number is greater than array bounds
print("you are asking out of bounds")
}
}
//insert
func save(name: String, ssn : Int16) {
let person = CoreDataManager.sharedManager.insertPerson(name: name, ssn: ssn)
if person != nil {
people.append(person!)
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
save(name: "joe", ssn: 3343)}