Cómo solucionar el error: esta clase no es compatible con la codificación del valor de la clave para la tabla tableView '. [duplicar]
Esta pregunta ya tiene una respuesta aquí:
esta clase no es compatible con la codificación del valor clave para la vista clave [duplicado] 7 respuestasHice una aplicación conTable View
ySegmented Control
, y esta es mi primera vez. Estoy usando un código y algunos tutoriales, pero no funciona. Cuando ejecuto mi aplicación, se bloquea y muestra este error en los registros:
MyApplication [4928: 336085] * Aplicación finalizada debido a la excepción no detectada 'NSUnknownKeyException', razón: '[setValue: forUndefinedKey:]: esta clase no es compatible con la codificación del valor de clave para la tabla de tabla clave'. * Primera llamada de lanzamiento de la pila: (0 CoreFoundation 0x000000010516fd85 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000105504deb objc_exception_throw + 48 2 CoreFoundation 0x000000010516f9c9 - [NSException raise] UIKit 0x0000000103c37d0c - [UIViewController setValue: forKey:] + 88 5 UIKit 0x0000000103e6e7fb - [UIRuntimeOutletConnection cONNECT] + 109 6 CoreFoundation 0x00000001050a9890 - [NSArray makeObjectsPerformSelector:] + 224 7 UIKit 0x0000000103e6d1de - [UINib instantiateWithOwner: opciones:] + 1,864 8 UIKit 0x0000000103c3e8d6 - [UIViewController _loadViewFromNibNamed: bundle:] + 381 9 UIKit 0x0000000103c3f202 - [UIViewController loadView] + 178 10 UIKit 0x0000000103c3f560 - [UIViewController loadViewIfRequired] + 138 11 UIKit 0x0000000103c3fcd3 - [Ver UIViewController] + 27 12 UIKit 0x000000010440b024 - [_ UIFullscreenPresentationController _setPresentedViewController:] + 87 13 UIKit 0x0000000103c0f5ca - [UIPresentationController initWithPresentedViewController: presentingViewController:] + 133 14 UIKit 0x0000000103c525bb - [UIViewController _presentViewController: withAnimationController: completado:] + 4,002 15 UIKit 0x0000000103c5585c - [UIViewController _performCoordinatedPresentOrDismiss: animado:] + 489 16 UIKit 0x0000000103c5536b - [UIViewController presentViewController: animada: completado:] + 179 17 0x00000001041feb8d UIKit __67- [UIStoryboardModalSegueTemplate newDefaultPerformHandlerForSegue:] _ block_invoke + 243 18 UIKit 0x00000001041ec630 - [UIStoryboardSegueTemplate _performWithDestinationViewController: remitente:] + 460 19 UIKit 0x00000001041ec433 - [_perform UIStoryboardSegueTemplate:] 0x00000001041ec6f7 + 82 20 UIKit - [UIStoryboardSegueTemplate realizar:] + 156 21 UIKit 0x0000000103aa6a8d - [UIApplication sendAction: to: from: forEvent:] + 92 22 UIKit 0x0000000103c19e67 - [UIControl sendAction: to: forEvent:] + 67 23 UIKit 0x0000000103c1a143 - [UIControlEveve: 3 UI. _UIApplicationHandleEventQueue + 6660 29 CoreFoundation 0x0000000105095301 _CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION_ + 17 30 CoreFoundation 0x000000010508b22c __CFRunLoopDoSources0 + 556 31 CoreFoundation 0x000000010508a6e3 __CFRunLoopRun + 867 32 CoreFoundation 0x000000010508a0f8 CFRunLoopRunSpecific + 488 33 GraphicsServices 0x000000010726dad2 GSEventRunModal + 161 34 UIKit 0x0000000103aa4f09 UIApplicationMain + 171 35 dhikr 0x0000000101f26282 principal + 114 36 libdyld.dylib 0x00000001064c392d inicio + 1) libc ++ abi.dylib: termina con una excepción no capturada del tipo NSException
El código que usé es:
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
let foodList:[String] = ["Bread", "Meat", "Pizza", "Other"]
let drinkList:[String] = ["Water", "Soda", "Juice", "Other"]
@IBOutlet weak var mySegmentedControl: UISegmentedControl!
@IBOutlet weak var myTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var returnValue = 0
switch(mySegmentedControl.selectedSegmentIndex) {
case 0:
returnValue = foodList.count
break
case 1:
returnValue = drinkList.count
break
default:
break
}
return returnValue
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let myCell = tableView.dequeueReusableCellWithIdentifier("myCells", forIndexPath: indexPath)
switch(mySegmentedControl.selectedSegmentIndex) {
case 0:
myCell.textLabel!.text = foodList[indexPath.row]
break
case 1:
myCell.textLabel!.text = drinkList[indexPath.row]
break
default:
break
}
return myCell
}
@IBAction func segmentedControlActionChanged(sender: AnyObject) {
myTableView.reloadData()
}
Aquí estámain.Storyboard
Revisé el código muchas veces, pero no funciona. Primero tuve que usar soloTable View
, viendo este tutorial (https://www.youtube.com/watch?v=ABVLSF3Vqdg) Pensé que funcionaría usarSegmented Control
como en el tutorial Pero aun así no funciona. Mismo código, mismo error. Alguien me puede ayudar ?