0

Getting an error regarding the depreciation of API 'set value for key on a NSObject'

enter image description here

I am upgrading my code to Swift 4.2 . While upgrading in runtime the code is crashing at this point.

object.setValue(valueToSet, forKey: key)
paresh
  • 130
  • 9
  • looking at the error, it seems like the problem is at `streetAddress1` and not the line of code you just posted. – regina_fallangi Aug 22 '18 at 18:15
  • To make `setValue(_:forKey:)` work, the properties set need to have `@objc`-setter. Have you added `@objc` on such properties? Especially on `streetAddress1`? – OOPer Aug 22 '18 at 19:32
  • I have created replica classes of all CoreData entities I have, each entity has lots of attribute. I have a common method which maps the all the attribute of the entity to its respective NSObject Classes. So adding @objc to all attribute is the real solution here? – paresh Aug 23 '18 at 06:23

1 Answers1

0

Here you have to add @objcMembers to the NSObject class.

paresh
  • 130
  • 9