D
D
davchikf02020-08-31 16:01:44
iOS
davchikf0, 2020-08-31 16:01:44

How to make Core Data friends with Cyrillic?

Help, I'm writing data to CoreData (self-written log), but when outputting, all Russian letters are displayed in the form \u....\u....\ and so on. Can this be translated to UTF-8? In JSON, this was solved by codable / decodable, I don’t really want to resort to this here.
I write like this:

public func toDoCoreData() {
                let appDelegate = UIApplication.shared.delegate as! AppDelegate
                let context = appDelegate.persistentContainer.viewContext
                let entity = NSEntityDescription.entity(forEntityName: "LogTable", in: context)
                let newUser = NSManagedObject(entity: entity!, insertInto: context)
                newUser.setValue(Date(), forKey: "date_log")
                newUser.setValue(string1, forKey: "str")
                newUser.setValue("entry", forKey: "type_log")
                
                do {
                    
                    try context.save()
                    
                } catch {
                    
                    print("Failed saving")
                }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question