This error is strange:
-[<>.Tips setTipName:]: unrecognized selector sent to instance <>
the name setTipName does not occur anywhere in the code but there is a variable tipName (note the lower case "t"
I am attempting to insert a row into a CoreData entity
class Tips: NSManagedObject {
@NSManaged var sectionNumber: NSNumber
@NSManaged var tipDescription: String
@NSManaged var viewName: String
@NSManaged var tipName: String
@NSManaged var tipOrder: NSNumber
@NSManaged var tipType: String
@NSManaged var tipLinkName: String
}
Here is the code doing the insert:
func createNewTips ()
{
// set create all switches and set to off
var error: NSError? = nil
var textCount = textArray.count
for var i = 0; i<textCount; ++i
{
var newTip = NSEntityDescription.insertNewObjectForEntityForName("Tips", inManagedObjectContext: managedObjectContext!) as! Tips
newTip.viewName = viewName
newTip.tipName = textArray [i].tipName
NSLog("after tipName")
newTip.tipDescription = textArray[i].tipDescription
NSLog("after set tipDescription")
newTip.tipOrder = textArray[i].tipOrder
NSLog("after set tipOrder")
newTip.sectionNumber = textArray[i].sectionNumber
NSLog("after set sectionNumber")
newTip.tipType = textArray[i].type
NSLog("after set type")
newTip.tipLinkName = textArray[i].tipLinkName
var error: NSError? = nil
if !managedObjectContext!.save(&error) {
NSLog("error &d", error!)
abort()
} // end save
} // end loop
} // end of createNewSwitches
I've recreated the data model several times
I've also changed the order of the attributes and the error occurs on a different attribute .. I've noticed that it appears to be the first attribute when I move the viewName attribute later in the list.
Here is the code in textArray
var textArray:[(sectionNumber: Int, tipOrder: Int, tipName: String, tipDescription: String, type: String, tipLinkName:String)] =
[
(1,0,"sw1","Check in and around your home for damage","text",""),
(1,1,"sw2","Dispose of any spoiled or contaminated foods, especially after a power outage. If you’re not sure, throw it out. You can check the food safety tips below","text",""),
(1,2,"sw3","Encourage family members to talk about their experience and their feelings, especially children","text",""),
(1,3,"sw4","Contact other family members to let them know that you are safe","text",""),
(2,0,"sw5","Check Utilities","link",""),
(3,0,"sw6","Food Safety Tips","link",""),
]
Any suggestions about this?
propertyName = someValue;
, you are invoking thesetPropertyName
method. – Hot Licks