Sign Up Not Working - Parse - Swift 2 - ios

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.

Related

Why do I get an "unrecognized selector" error with my IBAction?

I want to open a web page through a link. I'm using the address as a global variable. However, when I run a global function, an error occurs. What is the reason?
GlobalValue.swift
import Foundation
struct Global {
let apiAddress = "http://11.111.111.111:11111/"
let LinkURL: String
let LinkSecond : String
init()
{
agreeLinkURL = "User?type=webview"
agreeLinkSecond = "User2?type=webview"
}
func getURL() -> String {
return apiAddress + LinkURL
}
func getURLSecond() -> String {
return apiAddress + LinkSecond
}
}
Usage
let dataUrl = Global()
class ViewController: UIViewController {
...
#IBAction func DetailFuc(_ sender: Any) {
let detailUrl = dataUrl.getURL() // get error
print("***********************************************")
print(detailUrl)
print("***********************************************")
if let appURL = URL(string: detailUrl) {
UIApplication.shared.open(appURL) { success in
if success {
print("The URL was delivered successfully.")
} else {
print("The URL failed to open.")
}
}
} else {
print("Invalid URL specified.")
}
}
Error is:
2019-09-05 15:03:06.094723+0900 testap[24311:376425] -[testap.ViewController Detailfuc:]: unrecognized selector sent to instance 0x7ff27fe2d480
2019-09-05 15:03:06.102115+0900 testap[24311:376425] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[testap.ViewController Detailfuc:]: unrecognized selector sent to instance 0x7ff27fe2d480'
*** First throw call stack:
(
0 CoreFoundation 0x0000000105a618db __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000103fb8ac5 objc_exception_throw + 48
2 CoreFoundation 0x0000000105a7fc94 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKitCore 0x000000010f0bb235 -[UIResponder doesNotRecognizeSelector:] + 287
4 CoreFoundation 0x0000000105a66623 ___forwarding___ + 1443
5 CoreFoundation 0x0000000105a68418 _CF_forwarding_prep_0 + 120
6 UIKitCore 0x000000010f090624 -[UIApplication sendAction:to:from:forEvent:] + 83
7 UIKitCore 0x000000010eae58d5 -[UIControl sendAction:to:forEvent:] + 67
8 UIKitCore 0x000000010eae5bf2 -[UIControl _sendActionsForEvents:withEvent:] + 450
9 UIKitCore 0x000000010eae4ba8 -[UIControl touchesEnded:withEvent:] + 583
10 UIKitCore 0x000000010f0c94e6 -[UIWindow _sendTouchesForEvent:] + 2547
11 UIKitCore 0x000000010f0cabca -[UIWindow sendEvent:] + 4079
12 UIKitCore 0x000000010f0a930e -[UIApplication sendEvent:] + 356
13 UIKitCore 0x000000010f1792b3 __dispatchPreprocessedEventFromEventQueue + 3232
14 UIKitCore 0x000000010f17bbd9 __handleEventQueueInternal + 5911
15 CoreFoundation 0x00000001059c8db1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
16 CoreFoundation 0x00000001059c8633 __CFRunLoopDoSources0 + 243
17 CoreFoundation 0x00000001059c2cef __CFRunLoopRun + 1231
18 CoreFoundation 0x00000001059c24d2 CFRunLoopRunSpecific + 626
19 GraphicsServices 0x000000010a69f2fe GSEventRunModal + 65
20 UIKitCore 0x000000010f08efc2 UIApplicationMain + 140
21 testap 0x00000001035c31eb main + 75
22 libdyld.dylib 0x0000000107dcf541 start + 1
)
l
ibc++abi.dylib: terminating with uncaught exception of type NSException
Something must have been wrong when I set up a global variable, but I don't know what went wrong. Please let me know how to solve this. Is the method of calling a webpage the right way?
As you can see here:
reason: '-[testap.ViewController Detailfuc:]: unrecognized selector sent to instance 0x7ff27fe2d480'
That's not the issue. The reason of the crash is you renamed Detailfuc to DetailFuc with capital F. So it can not find the original function with lowercase f and crashed.
You should disconnect the wrong IBAction from the button eachtime you change the target.
You can right click on the button to see the connections and then click on x for the wrong connection with lowercase f
(reason: '-[testap.ViewController Detailfuc:]: unrecognized selector)
when you connect the outlet object in storyboard to it's code in the view controller, you can't modify the name any time before you disconnect it by right clicking on the object in story board and press on the x button that link the object with the code, and after modifying the name from code link it again.

Unable to connect to parse after recent update

Since the latest update, I get the error
"libc++abi.dylib: terminating with uncaught exception of type
NSException
(lldb)"
whenever I try to connect to parse
I can't even perform a simple task like create a user, as it will always crash. I suspect something changed after Xcode's recent update, and I cannot figure out what it is.
I suspect it could be the libc++abi.dylib library not been supported, but I don't know what to do about this.
Here's my View controller
import UIKit
import Parse
class ViewController: UIViewController {
#IBOutlet var username: UITextField!
#IBOutlet var password: UITextField!
func displayAlert(title: String, message: String) {
let alertcontroller = UIAlertController(title: title, message: message, preferredStyle: .alert)
alertcontroller.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
self.present(alertcontroller, animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
#IBAction func signup(_ sender: Any) {
if username.text == "" || password.text == "" {
displayAlert(title: "Error in Form", message: "Please fill in the information")
} else {
let user = PFUser()
user.username = username.text
user.password = password.text
}
}
Here's my App Delegate
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
//--------------------------------------
// MARK: - UIApplicationDelegate
//--------------------------------------
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Enable storing and querying data from Local Datastore.
// Remove this line if you don't want to use Local Datastore features or want to use cachePolicy.
Parse.enableLocalDatastore()
let parseConfiguration = ParseClientConfiguration(block: { (ParseMutableClientConfiguration) -> Void in
ParseMutableClientConfiguration.applicationId = "......"
ParseMutableClientConfiguration.clientKey = "......"
ParseMutableClientConfiguration.server = "........"
})
Parse.initialize(with: parseConfiguration)
Here's the error
019-05-22 12:51:10.776625+0200
ParseStarterProject-Swift[18144:1046582] [MC] System group container
for systemgroup.com.apple.configurationprofiles path is
/Users/ejike/Library/Developer/CoreSimulator/Devices/8AAB1103-8B3E-4584-BFAE-170720DE4BEF/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2019-05-22 12:51:10.780381+0200
ParseStarterProject-Swift[18144:1046582] [MC] Reading from private
effective user settings.
2019-05-22 12:51:23.291890+0200
ParseStarterProject-Swift[18144:1046582] *** Terminating app due to
uncaught exception 'NSInternalInconsistencyException', reason: 'The
class PFUser must be registered with registerSubclass before using
Parse.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107dad6fb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000107351ac5 objc_exception_throw + 48
2 CoreFoundation 0x0000000107dad555 +[NSException raise:format:] + 197
3 ParseStarterProject-Swift 0x0000000105f5a7e1 -[PFObject init] + 189
4 ParseStarterProject-Swift 0x0000000105f26533 $sSo6PFUserCABycfcTO +
19
5 ParseStarterProject-Swift 0x0000000105f25bdf $sSo6PFUserCABycfC + 31
6 ParseStarterProject-Swift 0x0000000105f25647
$s25ParseStarterProject_Swift14ViewControllerC6signupyyypF + 1383
7 ParseStarterProject-Swift 0x0000000105f25c3c
$s25ParseStarterProject_Swift14ViewControllerC6signupyyypFTo + 76
8 UIKitCore 0x0000000114799204 -[UIApplication
sendAction:to:from:forEvent:] + 83
9 UIKitCore 0x00000001141eec19 -[UIControl sendAction:to:forEvent:] +
67
10 UIKitCore 0x00000001141eef36 -[UIControl
_sendActionsForEvents:withEvent:] + 450
11 UIKitCore 0x00000001141edeec -[UIControl touchesEnded:withEvent:] +
583
12 UIKitCore 0x00000001147d1eee -[UIWindow _sendTouchesForEvent:] +
2547
13 UIKitCore 0x00000001147d35d2 -[UIWindow sendEvent:] + 4079
14 UIKitCore 0x00000001147b1d16 -[UIApplication sendEvent:] + 356
15 UIKitCore 0x0000000114882293
__dispatchPreprocessedEventFromEventQueue + 3232
16 UIKitCore 0x0000000114884bb9 __handleEventQueueInternal + 5911
17 CoreFoundation 0x0000000107d14be1
CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
18 CoreFoundation 0x0000000107d14463 __CFRunLoopDoSources0 + 243
19 CoreFoundation 0x0000000107d0eb1f __CFRunLoopRun + 1231
20 CoreFoundation 0x0000000107d0e302 CFRunLoopRunSpecific + 626
21 GraphicsServices 0x000000010cf112fe GSEventRunModal + 65
22 UIKitCore 0x0000000114797ba2 UIApplicationMain + 140
23 ParseStarterProject-Swift 0x0000000105f27dab main + 75
24 libdyld.dylib 0x00000001091a3541 start + 1
25 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type
NSException
(lldb)

Error when I return on TableViewController (swift)

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.

Function for UIBarButtonItem

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

Facebook and Twitter Share Error Swift

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.

Resources