코어데이터 #CoreData #NSPredicate #predicate1 [iOS] CoreData에서 특정 Entity 내부에 있는 Entity의 특정값을 가져오고 싶을 때(NSPredicate) 코어데이터를 사용하는 방법을 연습하다가 생긴 일이다. 먼저 entity로는 UserMO와 JokeMO 두개가 있다. User와 Joke는 Model도 있다. 여기서 보면 알 수 있듯이 User는 Joke 배열을 가지고 있다. 때문에 특정한 User의 특정 카테고리를 갖는 Joke만 선별하고 싶은 과정에서 문제가 있었다. func fetchWithPredicate(currentUser: User, currentCategory: Category) -> [Joke] { var jokes = [Joke]() let fetchRequest: NSFetchRequest = UserMO.fetchRequest() let idPredicate = NSPredicate(format: "id = %@", currentUs.. 2023. 12. 20. 이전 1 다음