First of all i wanne apologize for the code that will be used. I'am completely new to programming in general and it probably looks like .... :)
My problem is the following;
I have 1 ViewController (VC1) with 2 embedded container views (both TableViewControllers). Causs of the UI layout i want for my app i couldn't just use 1 TableVieController. Both of these container views have Textfields, labels, pickerviews that needs to be provided with data by the user. Now i want to save all this data with 1 button from the VC1.
Everything displays without error but when i tap the save button is gives me the following error: Could not cast value of type AddRaptorTableVCContainerOne' (0x1099ad840) to AddRaptorTableVCContainerTwo' (0x1099ad270).
Thanks in advance!
@IBAction func addRaptorSaveButton(sender: UIBarButtonItem) {
// Reference to childViewController
let childViewOne = childViewControllers.last as! AddRaptorTableVCContainerOne
let childViewTwo = childViewControllers.last as! AddRaptorTableVCContainerTwo
// Reference moc
let manObjCon = self.manObjCon
let addRaptorEntity = NSEntityDescription.entityForName("AddRaptorEntity", inManagedObjectContext: manObjCon!)
// Create instance of data model and initialize
var newRaptor = AddRaptorEntity(entity: addRaptorEntity!, insertIntoManagedObjectContext: manObjCon)
// Map our properties
newRaptor.image = UIImageJPEGRepresentation(self.addImageView.image, 1)
newRaptor.name = childViewOne.nameTextField.text
newRaptor.ringNo = childViewTwo.ringNoInputTextField.text
// Save our context
var error: NSError?
manObjCon!.save(nil)
println(newRaptor)