I created a function. This function is called by a button. If I press the button the app crashes and throws the following error:
2014-12-23 18:42:59.966 MyApp[8775:115552] -[MyApp.ViewController setDate]: unrecognized selector sent to instance 0x7fbbb9e458a0
2014-12-23 18:42:59.980 MyApp[8775:115552] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MyApp.ViewController setDate]: unrecognized selector sent to instance 0x7fbbb9e458a0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010451cf35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000106060bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010452404d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010447c27c ___forwarding___ + 988
4 CoreFoundation 0x000000010447be18 _CF_forwarding_prep_0 + 120
5 Foundation 0x00000001049512b4 __NSFireTimer + 83
6 CoreFoundation 0x0000000104484f64 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
7 CoreFoundation 0x0000000104484b25 __CFRunLoopDoTimer + 1045
8 CoreFoundation 0x0000000104447e5d __CFRunLoopRun + 1901
9 CoreFoundation 0x0000000104447486 CFRunLoopRunSpecific + 470
10 GraphicsServices 0x0000000106c289f0 GSEventRunModal + 161
11 UIKit 0x0000000104da8420 UIApplicationMain + 1282
12 MyApp 0x0000000103f6a08e top_level_code + 78
13 MyApp 0x0000000103f6a0ca main + 42
14 libdyld.dylib 0x0000000107834145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
this is the function which is crashing if it's called:
func setDate(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
switch editingStyle {
case .Delete:
let appDel:AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
let context:NSManagedObjectContext = appDel.managedObjectContext!
context.deleteObject(daten[indexPath.row] as NSManagedObject)
daten.removeAtIndex(indexPath.row)
context.save(nil)
self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
default:
let mySelectedCell:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)!
mySelectedCell.detailTextLabel?.text = dateLabel.text
self.sideBar.alpha = 0
return
}
}