unrecognized-selector

Adding a target to a button programmatically throws an error “unrecognized selector sent to class”

只谈情不闲聊 提交于 2021-02-04 14:19:45
问题 Not sure why I am getting an "Unrecognized selector sent to class" error when I try to use the button I've created in code. Here is my code: let sendButton: UIButton = { let button = UIButton(type: .system) button.setTitle("Send", for: .normal) button.setTitleColor(UIColor.white, for: .normal) button.backgroundColor = #colorLiteral(red: 0.5098039216, green: 0.5215686275, blue: 0.8392156863, alpha: 1) button.layer.cornerRadius = 5 button.isUserInteractionEnabled = true button.addTarget(self,

Adding a target to a button programmatically throws an error “unrecognized selector sent to class”

让人想犯罪 __ 提交于 2021-02-04 14:19:05
问题 Not sure why I am getting an "Unrecognized selector sent to class" error when I try to use the button I've created in code. Here is my code: let sendButton: UIButton = { let button = UIButton(type: .system) button.setTitle("Send", for: .normal) button.setTitleColor(UIColor.white, for: .normal) button.backgroundColor = #colorLiteral(red: 0.5098039216, green: 0.5215686275, blue: 0.8392156863, alpha: 1) button.layer.cornerRadius = 5 button.isUserInteractionEnabled = true button.addTarget(self,

Swift Selector with default argument

。_饼干妹妹 提交于 2020-03-23 07:19:21
问题 I have Write simple Code here self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Cancel, target: self, action: Selector("cancelClick")) Actual Function func cancelClick(isAlert:String = "yes"){ self.dismissViewControllerAnimated(true, completion: { () -> Void in if isAlert == "yes" { Functions.displayAlert("called") } }) } self.cancelClick() - Worked but if i didn't pass the argument self.cancelClick(isAlert:"no") - Crashed So what should be my

Swift Selector with default argument

帅比萌擦擦* 提交于 2020-03-23 07:19:13
问题 I have Write simple Code here self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Cancel, target: self, action: Selector("cancelClick")) Actual Function func cancelClick(isAlert:String = "yes"){ self.dismissViewControllerAnimated(true, completion: { () -> Void in if isAlert == "yes" { Functions.displayAlert("called") } }) } self.cancelClick() - Worked but if i didn't pass the argument self.cancelClick(isAlert:"no") - Crashed So what should be my

NSMutableArray addObjects - unrecognized-selector

前提是你 提交于 2020-01-21 20:33:06
问题 This is how I initialize my NSMutablearray. I copy the content of cityList into cityArray. Both are NSMutableArray. FYI, I declared the'cityArray' using extern. cityArray = [[NSMutableArray alloc] init]; [cityArray addObjectsFromArray:cityList]; Then, in other method in another class, I tried to to add one more object into 'cityArray' This is how I do it. But it keep crashing when it run this line of code. NSString *allCities = @"All Cities"; [[cityArray valueForKey:@"cityName"] addObject

[UILabel numberOfComponentsInPickerView:]: unrecognized selector sent to instance …]

浪子不回头ぞ 提交于 2020-01-16 05:18:06
问题 In my iOS app I have created a table view controller with custom cells where one of them contains a PickerView. Here's the class for that custom cell: import Foundation import UIKit class PickerCell: UITableViewCell { @IBOutlet weak var label : UILabel! @IBOutlet weak var pickerView : UIPickerView! func configurePickerCell(labelText:String, pickerDelegate:MyPickerViewController, enabled:Bool, defaultValueIndex:Int) { self.label.text = labelText var labelFrame:CGRect = self.label.frame

“unrecognized selector sent to class” when calling category method from a library

那年仲夏 提交于 2020-01-12 03:32:06
问题 Problem This question may seem a bit long, but I try to give as much information as possible, since I am really staggered by this. I am currently working an a library which should automate XML document parsing. But I am running into a problem now testing the library for the first time. I have a library class called CSXDocumentLayout which represents the layout of a document. This class contains the private method - (NSError *)readLayoutDocument:(NSString *)fpath called from an init method. /*

Unrecognized selector sent to instance while archiving data (NSCoding)

回眸只為那壹抹淺笑 提交于 2020-01-09 09:59:25
问题 -(void)transformObjects:(NSMutableArray*)array key:(NSString*)key { NSMutableArray* archiveArray = [[NSMutableArray alloc]initWithCapacity:array.count]; for (Furniture *furniture in array) { // The error occurs on the line below NSData *furnitureEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:furniture]; [archiveArray addObject:furnitureEncodedObject]; } NSUserDefaults *userData = [NSUserDefaults standardUserDefaults]; [userData setObject:archiveArray forKey:key]; } Error log:

Error : Xcode 4.6.3 - Method dragFromToForDuration does not work at all

浪尽此生 提交于 2020-01-05 04:02:08
问题 I use method dragFromToForDuration to test my app on iPad. This method intends to tap and hold then drag an image to another location on the iPad's screen. I define exactly location of both the image and the targeted area. However, implementing this method generates an error: target.dragFromToForDuration({x:startCoord.x, y:startCoord.y}, {x:finishCoord.x, y:finishCoord.y}, {duration:3}); [_NSCFDictionary doubleValue] : unrecognized selector sent to instance 0x1f83e5d0 Update: If I remove the

`unrecognized selector sent to instance <OBJ_ADR>`after sending `dismissViewControllerAnimated:completion` to a UIViewController

别等时光非礼了梦想. 提交于 2019-12-29 09:19:29
问题 Lots of similar questions but non with a solution that works in my case. I try to write a simple FlipSideApp. Just two views with a single button each (flipBtn | flopBtn) to present the other view vice versa. flip on the first view works fine. flop on the other view causes a unrecognized selector sent to instance 0x6c3adf0 . The App crashes after calling [self dismissViewControllerAnimated:YES completion:nil]; in file FlipSide.m (see code below). Where 0x6c3adf0 is the current address of self