I'm getting this error when Trying to share on facebook or twitter.
2015-04-12 17:49:42.208 TestShareApp[1069:30252] *** Assertion failure in -[UICGColor encodeWithCoder:], /SourceCache/UIKit_Sim/UIKit-3347.44/UIColor.m:1448
2015-04-12 17:49:42.359 TestShareApp[1069:30252] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only RGBA or White color spaces are supported in this situation.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000110424c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010fce0bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000110424aca +[NSException raise:format:arguments:] + 106
3 Foundation 0x000000010f24298f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 UIKit 0x0000000110c8379a -[UIColor encodeWithCoder:] + 972
5 Foundation 0x000000010f1f13e5 _encodeObject + 1120
6 Foundation 0x000000010f1f0c49 +[NSKeyedArchiver archivedDataWithRootObject:] + 162
7 UIKit 0x0000000110f842f7 -[_UIAppearanceRecorder _recordInvocation:withClassName:containerClassNames:traitCollection:selectorString:forRemoteProcess:] + 1915
8 UIKit 0x0000000110f7ef5d __54+[_UIAppearance _recordersExcludingSource:withWindow:]_block_invoke + 907
9 CoreFoundation 0x0000000110364656 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 102
10 CoreFoundation 0x000000011036455c -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
11 UIKit 0x0000000110f7ebc0 +[_UIAppearance _recordersExcludingSource:withWindow:] + 137
12 UIKit 0x000000011114897d UIViewServiceCurrentAppearanceSerializedRepresentations + 77
13 UIKit 0x000000011103bcc9 +[_UIRemoteViewController _requestViewController:traitCollection:fromServiceWithBundleIdentifier:service:connectionHandler:] + 232
14 UIKit 0x000000011103bbaa +[_UIRemoteViewController requestViewControllerWithService:connectionHandler:] + 91
15 UIKit 0x0000000110f13db8 __117-[NSExtension(UIViewControllerAdditions) instantiateViewControllerWithInputItems:listenerEndpoint:connectionHandler:]_block_invoke_2 + 621
16 libdispatch.dylib 0x000000011220e186 _dispatch_call_block_and_release + 12
17 libdispatch.dylib 0x000000011222d614 _dispatch_client_callout + 8
18 libdispatch.dylib 0x0000000112215a1c _dispatch_main_queue_callback_4CF + 1664
19 CoreFoundation 0x000000011038c1f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
20 CoreFoundation 0x000000011034ddcb __CFRunLoopRun + 2043
21 CoreFoundation 0x000000011034d366 CFRunLoopRunSpecific + 470
22 GraphicsServices 0x0000000113f81a3e GSEventRunModal + 161
23 UIKit 0x0000000110a4d900 UIApplicationMain + 1282
24 TestShareApp 0x000000010e38d457 main + 135
25 libdyld.dylib 0x0000000112261145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
and here is my facebook and twitter actionsheet code
func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int) {
if buttonIndex == 1 { // Facebook
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook) {
var controller = SLComposeViewController(forServiceType:SLServiceTypeFacebook)
controller.setInitialText(shareText)
controller.addURL(NSURL(string: appUrl) )
self.presentViewController(controller, animated: true, completion: nil)
controller.completionHandler = { (result:SLComposeViewControllerResult) -> Void in
switch result {
case SLComposeViewControllerResult.Cancelled:
println("fb cancel")
case SLComposeViewControllerResult.Done:
println("done")
}
}
} else {
var alert = UIAlertView(title: "No Facebook Account", message: "Oops, you've not added facebook account in your iphone settings", delegate: self, cancelButtonTitle: "Okay")
alert.show()
}
} else if buttonIndex == 2 { // Twitter
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter) {
var controller = SLComposeViewController(forServiceType:SLServiceTypeTwitter)
controller.setInitialText(shareText)
controller.addURL(NSURL(string: appUrl) )
self.presentViewController(controller, animated: true, completion: nil)
controller.completionHandler = { (result:SLComposeViewControllerResult) -> Void in
switch result {
case SLComposeViewControllerResult.Cancelled:
println("fb cancel")
case SLComposeViewControllerResult.Done:
println("done")
}
}
} else {
var alert = UIAlertView(title: "No Twitter Account", message: "Oops! Looks like you've not added Twitter account in your settings", delegate: self, cancelButtonTitle: "Okay")
alert.show()
}
}
}
same code works fine on my other apps. Not sure why this is happeing when I click or either facebook or twitter.
Related
This question already has answers here:
UISwipeGestureRecognizer throw unrecognised selector sent error
(2 answers)
Closed 5 years ago.
Hello I added a swift gesture recognizer and it keeps crashing my program
override func viewDidLoad() {
super.viewDidLoad()
let leftSwipe = UISwipeGestureRecognizer(target: self, action: Selector(("handleSwipes:")))
let rightSwipe = UISwipeGestureRecognizer(target: self, action: Selector(("handleSwipes:")))
leftSwipe.direction = .left
rightSwipe.direction = .right
self.view.addGestureRecognizer(leftSwipe)
self.view.addGestureRecognizer(rightSwipe)
}
func handleSwipes(sender: UISwipeGestureRecognizer) {
if (sender.direction == .left ) {
headerLabel.text = "Zodiac Yearly"
}
if (sender.direction == .right ) {
headerLabel.text = "Characteristics"
}
}
This is the error I am getting
2017-09-08 20:17:33.355 Views[40942:2309262] -[Views.ViewController handleSwipes:]: unrecognized selector sent to instance 0x7fdd9bc0dc90
2017-09-08 20:17:33.361 Views[40942:2309262] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Views.ViewController handleSwipes:]: unrecognized selector sent to instance 0x7fdd9bc0dc90'
*** First throw call stack:
(
0 CoreFoundation 0x0000000111f40b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010f1e6141 objc_exception_throw + 48
2 CoreFoundation 0x0000000111fb0134 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000111ec7840 ___forwarding___ + 1024
4 CoreFoundation 0x0000000111ec73b8 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010fbecf59 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57
6 UIKit 0x000000010fbf4d57 _UIGestureRecognizerSendTargetActions + 109
7 UIKit 0x000000010fbf270b _UIGestureRecognizerSendActions + 225
8 UIKit 0x000000010fbf19ce -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 981
9 UIKit 0x000000010fbde152 _UIGestureEnvironmentUpdate + 1219
10 UIKit 0x000000010fbddc43 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 484
11 UIKit 0x000000010fbdce0a -[UIGestureEnvironment _updateGesturesForEvent:window:] + 274
12 UIKit 0x000000010f728eea -[UIWindow sendEvent:] + 4092
13 UIKit 0x000000010f6d5a84 -[UIApplication sendEvent:] + 352
14 UIKit 0x000000010feb95d4 __dispatchPreprocessedEventFromEventQueue + 2926
15 UIKit 0x000000010feb1532 __handleEventQueue + 1122
16 CoreFoundation 0x0000000111ee6c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
17 CoreFoundation 0x0000000111ecc0cf __CFRunLoopDoSources0 + 527
18 CoreFoundation 0x0000000111ecb5ff __CFRunLoopRun + 911
19 CoreFoundation 0x0000000111ecb016 CFRunLoopRunSpecific + 406
20 GraphicsServices 0x0000000113ed7a24 GSEventRunModal + 62
21 UIKit 0x000000010f6b8134 UIApplicationMain + 159
22 Views 0x000000010ec06a67 main + 55
23 libdyld.dylib 0x0000000112f6c65d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
let leftSwipe = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipes(sender:)))
#objc func handleSwipes(sender: UISwipeGestureRecognizer) {
// ...
}
This should work in Swift 3 and 4.
I'm a new Swift programmer. I'm building my first app with TableViewController + NavigationController.
In my app, I can see this:
If I click on Plus button I can see this View:
Then I compile all field and then I click on OK button. But I have this error:
2017-04-20 16:23:48.158 ArduinoHomeKit_bis[3238:795882] -[LuciKit id]: unrecognized selector sent to instance 0x61000026a700
2017-04-20 16:23:48.162 ArduinoHomeKit_bis[3238:795882] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LuciKit id]: unrecognized selector sent to instance 0x61000026a700'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107745b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001045c0141 objc_exception_throw + 48
2 CoreFoundation 0x00000001077b5134 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00000001076cc840 ___forwarding___ + 1024
4 CoreFoundation 0x00000001076cc3b8 _CF_forwarding_prep_0 + 120
5 ArduinoHomeKit_bis 0x0000000103fc0603 _TFC18ArduinoHomeKit_bis28ListaLuciTableViewController14tornaAllaListafCSo17UIStoryboardSegueT_ + 435
6 ArduinoHomeKit_bis 0x0000000103fc098a _TToFC18ArduinoHomeKit_bis28ListaLuciTableViewController14tornaAllaListafCSo17UIStoryboardSegueT_ + 58
7 UIKit 0x0000000105903bbf -[UIStoryboardUnwindSegueTemplate _performWithDestinationViewController:sender:] + 214
8 UIKit 0x0000000105903ab6 -[UIStoryboardUnwindSegueTemplate _perform:] + 83
9 UIKit 0x000000010566ea1f -[UIStoryboardSegueTemplate perform:] + 157
10 UIKit 0x0000000104ea8d22 -[UIApplication sendAction:to:from:forEvent:] + 83
11 UIKit 0x00000001052e35c7 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 149
12 UIKit 0x0000000104ea8d22 -[UIApplication sendAction:to:from:forEvent:] + 83
13 UIKit 0x000000010502d25c -[UIControl sendAction:to:forEvent:] + 67
14 UIKit 0x000000010502d577 -[UIControl _sendActionsForEvents:withEvent:] + 450
15 UIKit 0x000000010502d6eb -[UIControl _sendActionsForEvents:withEvent:] + 822
16 UIKit 0x000000010502c4b2 -[UIControl touchesEnded:withEvent:] + 618
17 UIKit 0x0000000104f1649a -[UIWindow _sendTouchesForEvent:] + 2707
18 UIKit 0x0000000104f17bb0 -[UIWindow sendEvent:] + 4114
19 UIKit 0x0000000104ec47b0 -[UIApplication sendEvent:] + 352
20 UIKit 0x00000001056a7adc __dispatchPreprocessedEventFromEventQueue + 2926
21 UIKit 0x000000010569fa3a __handleEventQueue + 1122
22 CoreFoundation 0x00000001076ebc01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
23 CoreFoundation 0x00000001076d10cf __CFRunLoopDoSources0 + 527
24 CoreFoundation 0x00000001076d05ff __CFRunLoopRun + 911
25 CoreFoundation 0x00000001076d0016 CFRunLoopRunSpecific + 406
26 GraphicsServices 0x00000001096fca24 GSEventRunModal + 62
27 UIKit 0x0000000104ea70d4 UIApplicationMain + 159
28 ArduinoHomeKit_bis 0x0000000103fc3ce7 main + 55
29 libdyld.dylib 0x00000001086e565d start + 1
30 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
After click OK this is the code that I try to execute:
#IBAction func tornaAllaLista(_ segue: UIStoryboardSegue){
do {
var vistaDettaglio: AggiungiLuceViewController = segue.source as! AggiungiLuceViewController
if(vistaDettaglio.nuovaLuce != nil && vistaDettaglio.nuovaLuce?.id == 0){
self.listaLuci.append(vistaDettaglio.nuovaLuce!)
self.tabella.reloadData()
}else{
}
} catch let errore {
print("[CDC] problema tornaAllaLista")
print(" Stampo l'errore: \n \(errore) \n")
}
}
EDIT
This is the code that I execute when I click on OK button:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
//se il pulsante cliccato è diverso da OK torno indietro
if sender as? NSObject != self.buttonOK{
return
}
let nomeLuce = self.textNomeLuce.text!
let pinArduino = Int16(self.textPinArduino.text!)
let tipoLuce = self.textTipoLuce.text!
if(nomeLuce.characters.count>0){
//ho inserito almeno un carattere
LuciKitCoreDataController.shared.addLuce(descrizione: nomeLuce, pin_arduino: Int(pinArduino!))
self.nuovaLuce = LuciKit()
self.nuovaLuce?.descrizione = nomeLuce
self.nuovaLuce?.pin_arduino = pinArduino!
self.nuovaLuce?.id = 3
}else{
let alert = UIAlertController(title:"Attenzione", message: "Inserire un nome per la Luce", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated:true, completion: nil)
}
}
If I try to execute this line code:
self.nuovaLuce?.descrizione = nomeLuce
I have an error
Pretty sure that this is the offending line:
vistaDettaglio.nuovaLuce?.id == 0
Object stored under novaLuce doesn't contain a method called -id, as it seems to be.
so I'm looking at using this GitHub api to that checks for the reachability of a host.: https://github.com/ashleymills/Reachability.swift/tree/feature/ios10
however its pretty bare bones and I'm getting a few errors when trying to write a function that will use this code. I'm calling it from viewdidload
setupReachability(hostName: nil)
var reachability:Reachability?
var connected = false
func setupReachability (hostName:String?) {
do {
let reachability = try hostName == nil ? Reachability() : Reachability(hostname: hostName!)
self.reachability = reachability
try! self.reachability?.startNotifier()
} catch ReachabilityError.FailedToCreateWithAddress(let address) {
print(address)
return
} catch {}
//now that the reacability function is created set a notification
NotificationCenter.default.addObserver(self, selector: "reachabilityChanged", name: ReachabilityChangedNotification, object: reachability)
}
func reachabilityChanged(notification: Notification) {
let reachability = notification.object as! Reachability
if reachability.isReachable {
if reachability.isReachableViaWiFi {
connected = true
print("Connected via WiFi")
} else {
connected = true
print("Connected via Cellular")
}
} else {
connected = false
print("Not Connected")
}
}
this is my error log:
2016-12-28 08:53:25.441 ParseStarterProject-Swift[92944:1919466] Simulator user has requested new graphics quality: 100
2016-12-28 08:53:29.697 ParseStarterProject-Swift[92944:1919546] -[ParseStarterProject_Swift.PackViewController reachabilityChanged]: unrecognized selector sent to instance 0x7fafabd0bb40
2016-12-28 08:53:29.712 ParseStarterProject-Swift[92944:1919546] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ParseStarterProject_Swift.PackViewController reachabilityChanged]: unrecognized selector sent to instance 0x7fafabd0bb40'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ad98d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010a7fa21e objc_exception_throw + 48
2 CoreFoundation 0x000000010ae08f04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010ad1e005 ___forwarding___ + 1013
4 CoreFoundation 0x000000010ad1db88 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x000000010ad365ec __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
6 CoreFoundation 0x000000010ad364eb _CFXRegistrationPost + 427
7 CoreFoundation 0x000000010ad36252 ___CFXNotificationPost_block_invoke + 50
8 CoreFoundation 0x000000010acf9282 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 2018
9 CoreFoundation 0x000000010acf831b _CFXNotificationPost + 667
10 Foundation 0x000000010a2c081b -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
11 ParseStarterProject-Swift 0x000000010983fabe _TFC25ParseStarterProject_Swift12ReachabilityP33_3EC4A4DB94B171724E68742C2AA9888E19reachabilityChangedfT_T_ + 462
12 ParseStarterProject-Swift 0x0000000109841205 _TFFC25ParseStarterProject_Swift12Reachability13startNotifierFzT_T_U_FT_T_ + 21
13 ParseStarterProject-Swift 0x0000000109811f17 _TTRXFo___XFdCb___ + 39
14 libdispatch.dylib 0x000000010df1b978 _dispatch_call_block_and_release + 12
15 libdispatch.dylib 0x000000010df450cd _dispatch_client_callout + 8
16 libdispatch.dylib 0x000000010df22e17 _dispatch_queue_serial_drain + 236
17 libdispatch.dylib 0x000000010df23b4b _dispatch_queue_invoke + 1073
18 libdispatch.dylib 0x000000010df2402b _dispatch_queue_override_invoke + 683
19 libdispatch.dylib 0x000000010df26385 _dispatch_root_queue_drain + 720
20 libdispatch.dylib 0x000000010df26059 _dispatch_worker_thread3 + 123
21 libsystem_pthread.dylib 0x000000010e39f712 _pthread_wqthread + 1299
22 libsystem_pthread.dylib 0x000000010e39f1ed start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
EDIT
You forgot a colon on the reachabilityChanged: selector. You need it to indicate that an argument is to be passed:
NotificationCenter.default.addObserver(self, selector: "reachabilityChanged:", name: ReachabilityChangedNotification, object: reachability)
When I clicked my "Sign Up" button after typing my username and password in, my app crashes. I am new to this type of programming and I have no idea why. This is my error:
2015-12-08 08:37:51.477 Scoop[835:19495] -[Scoop.CustomSignUpViewController SignUp:]: unrecognized selector sent to instance 0x7fa383cc8220
2015-12-08 08:37:51.484 Scoop[835:19495] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Scoop.CustomSignUpViewController SignUp:]: unrecognized selector sent to instance 0x7fa383cc8220'
*** First throw call stack:
(
0 CoreFoundation 0x0000000108960f45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010a684deb objc_exception_throw + 48
2 CoreFoundation 0x000000010896956d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00000001088b6eea ___forwarding___ + 970
4 CoreFoundation 0x00000001088b6a98 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010917ee91 -[UIApplication sendAction:to:from:forEvent:] + 92
6 UIKit 0x00000001092ea4d8 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x00000001092ea7a4 -[UIControl _sendActionsForEvents:withEvent:] + 311
8 UIKit 0x00000001092e98d4 -[UIControl touchesEnded:withEvent:] + 601
9 UIKit 0x00000001091eced1 -[UIWindow _sendTouchesForEvent:] + 835
10 UIKit 0x00000001091edc06 -[UIWindow sendEvent:] + 865
11 UIKit 0x000000010919d2fa -[UIApplication sendEvent:] + 263
12 UIKit 0x0000000109177abf _UIApplicationHandleEventQueue + 6844
13 CoreFoundation 0x000000010888d011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 CoreFoundation 0x0000000108882f3c __CFRunLoopDoSources0 + 556
15 CoreFoundation 0x00000001088823f3 __CFRunLoopRun + 867
16 CoreFoundation 0x0000000108881e08 CFRunLoopRunSpecific + 488
17 GraphicsServices 0x000000010bdd0ad2 GSEventRunModal + 161
18 UIKit 0x000000010917d30d UIApplicationMain + 171
19 Scoop 0x00000001075e463d main + 109
20 libdyld.dylib 0x000000010b19692d start + 1
21 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
This is my code for my sign up action:
#IBAction func SignUpAction(sender: AnyObject) {
var username = self.usernameField.text
var password = self.passwordField.text
var confirmPassword = self.confirmPasswordField.text
if (username?.characters.count > 4 || password?.characters.count > 5){
var alert = UIAlertView(title: "Oops!", message: "Username must be
greater than 4 & password must be greater than 5.", delegate: self,
cancelButtonTitle: "Okay")
alert.show()
}else if (password?.characters.count !=
confirmPassword?.characters.count){
var alert = UIAlertView(title: "Oops!", message: "Your passwords do
not match. Try again.", delegate: self, cancelButtonTitle: "Okay")
alert.show()
}else {
self.actInd.startAnimating()
var newUser = PFUser()
newUser.username = username
newUser.password = password
newUser.signUpInBackgroundWithBlock({ (succeed, error) -> Void in
self.actInd.stopAnimating()
if ((error) != nil) {
var alert = UIAlertView(title: "Error", message: "\(error)",
delegate: self, cancelButtonTitle: "Okay")
alert.show()
}else {
var alert = UIAlertView(title: "Success!", message: "You
have been signed up for Scoop!", delegate: self, cancelButtonTitle:
"Okay")
alert.show()
}
})
}
}
Rename your method
#IBAction func SignUpAction(sender: AnyObject){
to
#IBAction func SignUp(sender: AnyObject){
To prevent crashes like this you should read the error message carefully, it says:
-[Scoop.CustomSignUpViewController SignUp:]: unrecognized selector sent to instance...
That means that you try to call a method on your view controller which doesn't exist. Often it happens if you misspell a name of method ( you sent SignUp name, but in your view controller SignUpAction)
By the way, it would be better practice, according to guidelines, to name methods starting with lowercase character.
I'm using Core Data and I'm making a save button with this code:
self.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: Selector("saveTapped")), animated: true)
The save function:
func saveTapped(){
if (cell!.textField.text.isEmpty) {
let alert = UIAlertView()
alert.title = "Nevyplnené údaje"
alert.message = "Musíš vyplniť všetky údaje o knihe."
alert.addButtonWithTitle("Ok")
alert.show()
}
let appDel: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let obsah: NSManagedObjectContext = appDel.managedObjectContext!
let entity = NSEntityDescription.entityForName("List", inManagedObjectContext: obsah)
var pridat = Model(entity: entity! , insertIntoManagedObjectContext: obsah)
pridat.kniha = cell!.textField.text
pridat.autor = cell!.textField.text
pridat.rok = cell!.textField.text
pridat.vydavatelstvo = cell!.textField.text
pridat.strany = cell!.textField.text
obsah.save(nil)
}
This is the error I'm getting:
2015-04-29 19:12:42.762 iKnižnica[25716:11689183]
-[iKniz_nica.PridatViewController saveTapped]: unrecognized selector sent to instance 0x7ff5ab63ff50 2015-04-29 19:12:42.851
iKnižnica[25716:11689183] * Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason:
'-[iKniz_nica.PridatViewController saveTapped]: unrecognized selector
sent to instance 0x7ff5ab63ff50'
* First throw call stack: ( 0 CoreFoundation 0x0000000100bccc65 exceptionPreprocess + 165 1 libobjc.A.dylib
0x0000000102737bb7 objc_exception_throw + 45 2 CoreFoundation
0x0000000100bd40ad -[NSObject(NSObject) doesNotRecognizeSelector:] +
205 3 CoreFoundation 0x0000000100b2a13c
___forwarding_ + 988 4 CoreFoundation 0x0000000100b29cd8 _CF_forwarding_prep_0 + 120 5 UIKit
0x000000010146cda2 -[UIApplication sendAction:to:from:forEvent:] + 75
6 UIKit 0x000000010146cda2
-[UIApplication sendAction:to:from:forEvent:] + 75 7 UIKit 0x000000010157e54a -[UIControl _sendActionsForEvents:withEvent:] + 467
8 UIKit 0x000000010157d919
-[UIControl touchesEnded:withEvent:] + 522 9 UIKit 0x00000001014b9998 -[UIWindow _sendTouchesForEvent:] + 735 10 UIKit
0x00000001014ba2c2 -[UIWindow sendEvent:] + 682 11 UIKit
0x0000000101480581 -[UIApplication sendEvent:] + 246 12 UIKit
0x000000010148dd1c _UIApplicationHandleEventFromQueueEvent + 18265 13
UIKit 0x00000001014685dc
_UIApplicationHandleEventQueue + 2066 14 CoreFoundation 0x0000000100b00431
CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 15 CoreFoundation 0x0000000100af62fd
__CFRunLoopDoSources0 + 269 16 CoreFoundation 0x0000000100af5934 __CFRunLoopRun + 868 17 CoreFoundation
0x0000000100af5366 CFRunLoopRunSpecific + 470 18 GraphicsServices
0x0000000104bb3a3e GSEventRunModal + 161 19 UIKit
0x000000010146b900 UIApplicationMain + 1282 20 iKnizÃånica
0x00000001005c6377 main + 135 21 libdyld.dylib
0x0000000102e8f145 start + 1 ) libc++abi.dylib: terminating with
uncaught exception of type NSException (lldb)
I posted the source code here: http://pastebin.com/M9AMakGr
Problem is not in the button settings, but in function
Instead of:
func saveTapped(){
Should be:
func saveTapped(sender:UIButton){
Change your setRightBarButtonItem code to below code:
self.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "saveTapped:"), animated: true)
In swift, for selector you just need to type the name of the function, that's it! Hope it helps