Swift无法识别的select器发送到实例错误

我最近把我的项目从Objective-C转换到了Swift,并且这样做只要点击表格视图单元格中的一个button就会收到这个错误。 我有多个单元格正在填充从MySQL服务器的信息。 我有两个button,一个button和后面的button,当一个被点击时,另一个应该显示。 我一直在这个工作了一段时间,但我一直卡在这个错误。 当我点击tableview中的button时出现错误 CustomCellSwift[1425:372289] -[CustomCellSwift.ViewController followButtonClick:]: unrecognized selector sent to instance 0x100b13a40 在CustomCell.swift中 class CustomCell: UITableViewCell { @IBOutlet weak var firstStatusLabel: UILabel! @IBOutlet weak var secondStatusLabel: UILabel! @IBOutlet weak var myImageView: UIImageView! @IBOutlet weak var followButton: UIButton! @IBOutlet weak var followedButton: UIButton! override func awakeFromNib() { super.awakeFromNib() self.followButton.isHidden = true self.followedButton.isHidden = true […]

如何在iOS上安装同一个应用程序的两个版本?

我有应用程序Bundle dispaly Name “BobAppl”和Bundle identifier名为“org.bob.phone”。 我想安装新版本的相同的应用程序,但保存旧版本以及我的iPhone我想看到2应用程序:“BobAppl”和“BobApplNew”。 现在,如果我将Bundle dispaly Name更改为“BobApplNew”,我仍然敲下“BobAppl”。 我需要做什么? 我是否需要更改Bundle identifier或其他内容? 谢谢,

JSONparsing后–viewForAnnotation在MKMapView上只显示一个单一的注解

我需要在我的MkMapView上显示大约10个位置(和相应的注释),按下button之后,我需要根据不同的JSONparsing结果添加新的不同注释(例如locationIDValue <100表示​​红色针,否则为绿色)。 这是简化的代码: – (void)viewDidLoad { [super viewDidLoad]; map.showsUserLocation = true; map.mapType = MKMapTypeStandard; arrayID = [[NSMutableArray alloc] initWithObjects: @"id1", @"id2", @"id3", @"id4", @"id5", @"id6", @"id7", @"id8", @"id9", @"id10", nil]; #define MakeLocation(lat,lon) [[CLLocation alloc] initWithLatitude:lat longitude:lon] locations= @[ MakeLocation(lat1,lon1), MakeLocation(lat2,lon2), MakeLocation(lat3,lon3), MakeLocation(lat4,lon4), MakeLocation(lat5,lon5), MakeLocation(lat6,lon6), MakeLocation(lat7,lon7), MakeLocation(lat8,lon8), MakeLocation(lat9,lon9), MakeLocation(lat10,lon10) ]; for (int l=0; l<[locations count]; l++) […]

从iOS打开WatchKit应用程序

我想直接从我的iPhone上打开WatchKit应用程序到前台(或者Glance,如果可能的话)。 我一直在玩,但没有成功。 也许有人find了一些解决方法?

如何从swift中删除核心数据中的对象3

这是我如何将数据保存到核心,现在我想从整个数据中删除特定的对象。 我怎样才能做到这一点? 这是我如何保存数据: func saveProductDetails(product : Product) { // set user_id product.user_id = UserDefaults.sharedInstace.getCustomerId() //save data locally for the time been let entity = NSEntityDescription.entityForName("Product", inManagedObjectContext: self.writeContext) let category = NSEntityDescription.entityForName("Category", inManagedObjectContext: self.writeContext) let brand = NSEntityDescription.entityForName("Brand", inManagedObjectContext: self.writeContext) var entityProduct = NSManagedObject(entity: entity!, insertIntoManagedObjectContext:self.writeContext) var entityCategory = NSManagedObject(entity: category!, insertIntoManagedObjectContext:self.writeContext) var entityBrand = NSManagedObject(entity: […]

如何解决这个问题:“'实例方法'-arrayByPerformingSelector':找不到(返回types默认为'id')”

我看到在一个职位-(id)arrayByPerformingSelector声明在界面应该做的,但是当我尝试它这个声明被视为单独的方法和不完整的实现问题来了…对不起,这是相当愚蠢的疑问,我问,但我一个iOS新手,无法找出这是什么错误.. self.segmentedControl = [[UISegmentedControl alloc] initWithItems:[viewControllers arrayByPerformingSelector:@selector(title)]]; self.segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; 当我运行项目线程停止与SIGABRT和控制台窗口 "TableView[866:fe03] -[__NSArrayI arrayByPerformingSelector:]: unrecognized selector sent to instance 0x6e65620 2012-03-07 12:31:16.074 TableView[866:fe03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI arrayByPerformingSelector:]: unrecognized selector sent to instance 0x6e65620'" 如果我必须在声明中使用select器请告诉我如何….谢谢所有:) 🙂

在同步完成之前iOS NSUserDefaults访问

如果我设置了一个NSUserDefault对象,并在它被同步之前尝试访问它,我将能够访问我刚刚添加的对象吗? 我已经尝试编写代码来testing它,但是我不确定是否在没有我知道的情况下发生了同步 。

如何将文件写入位于Swift 4中Apple文件应用程序的文件夹?

我在我的Xcode项目中有一个XML文件,我试图先把它保存到磁盘,其次我怎么能告诉我,如果我已经成功地保存它? 这是正确的方法吗? 使用模拟器我导航到新的“文件”文件夹在iOS 11中,我没有看到它,但我不知道它应该在那里或没有? guard let path = Bundle.main.url(forResource: "sample", withExtension: "xml") else {print("NO URL"); return} let sample = try? Data(contentsOf: path) print("sample XML = \(String(describing: sample?.debugDescription))") //put xml file on the device let filename = getDocumentsDirectory().appendingPathComponent("sample.xml") do { try sample?.write(to: filename) } catch { print("ERROR") } 更新包括我的检查,如果文件存在: //check if file exists let checkPath = […]

将一个variables从一个视图控制器传递给另一个视图控制器

我新来的迅速语言,知道这个问题是重复的。我发现了几个类似的问题和答案,但我无法找出问题。 我想将scanStringvariables的值从ScanViewController传递给ResultViewController。 ScanViewcontroller如下: import UIkit class ScanViewController: UIViewController { var detectionString : String! override func viewDidLoad() { super.viewDidLoad() detectionString = “SomeDetectedString” } override func prepareForSegue(segue: UIStoryboardSegue,sender: AnyObject!) { if (segue.identifier == "MySegue") { var svc = segue.destinationViewController as ResultViewController; svc.detectedString = detectionString } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } } ResultViewController如下所示: import UIkit class […]

用于保存核心数据的NSPersistentContainer并发性

我已经阅读了一些关于这个的博客,但是我仍然对如何使用NSPersistentContainer performBackgroundTask创build实体并保存它感到困惑。 通过在performBackgroundTask() { (moc) in }块中调用便利方法init(context moc: NSManagedObjectContext)创build一个实例后,如果我检查container.viewContext.hasChanges这将返回false,并说没有什么可以保存,如果我调用保存moc (为这个块创build的背景MOC)我得到像这样的错误: fatal error: Failure to save context: Error Domain=NSCocoaErrorDomain Code=133020 "Could not merge changes." UserInfo={conflictList=( "NSMergeConflict (0x17466c500) for NSManagedObject (0x1702cd3c0) with objectID '0xd000000000100000 <x-coredata://3EE6E11B-1901-47B5-9931-3C95D6513974/Currency/p4>' with oldVersion = 1 and newVersion = 2 and old cached row = {id = 2; … }fatal error: Failure to save […]