小编Jor*_*mez的帖子

命令CompileSwift在Xcode 10中使用非零退出代码失败

下午好,

在更新到最新版本的Xcode(版本10.0)之后,项目无法构建,因为它发现了一些关于"Command CompileSwift失败并返回非零退出代码"错误的错误.

我该如何解决这个错误? 它们出现在我在项目中使用的大多数Pod(我使用CocoaPods)中.

我已经尝试将pod版本和pod更新到可用的最新版本,但问题仍然存在.

我在网上搜索了很多,关于这个问题的信息非常少.

问候.

xcode ios swift swift4 xcode10

87
推荐指数
12
解决办法
8万
查看次数

在iOS中的annotationView中自定义图钉图像

我正在尝试从Swift 1.2更改为Swift 2.0,而我正处于更改的末尾.目前我正在对MapViewController进行更改,并且没有任何错误或警告,但我的pin(annotationView)的自定义图像没有分配给引脚,而是显示默认值(红点).

这是我的代码,我希望你能帮助我一些提示,因为我认为一切都很好,但它仍然无法正常工作:

func parseJsonData(data: NSData) -> [Farmacia] {

    let farmacias = [Farmacia]()

    do
    {
        let jsonResult = try NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers) as? NSDictionary

        // Parse JSON data
        let jsonProductos = jsonResult?["farmacias"] as! [AnyObject]

        for jsonProducto in jsonProductos {

            let farmacia = Farmacia()
            farmacia.id = jsonProducto["id"] as! String
            farmacia.nombre = jsonProducto["nombre"] as! String
            farmacia.location = jsonProducto["location"] as! String

            let geoCoder = CLGeocoder()
            geoCoder.geocodeAddressString(farmacia.location, completionHandler: { placemarks, error in

                if error != nil {
                    print(error)
                    return
                }

                if placemarks != …
Run Code Online (Sandbox Code Playgroud)

mkmapview mkannotationview ios swift

18
推荐指数
2
解决办法
3万
查看次数

使用iOS 8的Swift 3中的Alamofire

我已经更新到最新版本的Xcode(8),在将代码升级到Swift 3之后,Alamofire突然停止工作并抛出了很多错误.

经过大量的研究,我发现Alamofire for Swift 3与iOS9 +兼容,所以现在我必须找到另一个适用于iOS8 +的版本.

你知道我怎样才能为iOS8的Alamofire提供相同的功能?

swift ios8 alamofire ios9 swift3

6
推荐指数
1
解决办法
2636
查看次数

在iOS 9中不推荐使用sendAsynchronousRequest

我正在尝试将我的代码从Swift 1.2更改为Swift 2.0,但我遇到了一些关于"sendAsynchronousRequest"的问题,因为它总是显示警告,因为它已被弃用.我尝试过使用此帖子中的其他解决方案:不能在Swift 2中使用参数列表调用'sendAsynchronousRequest'但它仍然无法工作,我再次收到相同的警告.

我必须在代码中更改以解决此警告?警告如下:

在iOS 9中不推荐使用sendAsynchronousRequest,使用dataTaskWithRequest:completionHandler

这是我的代码:

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

    // try to reuse cell
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! MarcaCollectionViewCell

    // get the deal image
    let currentImage = marcas[indexPath.row].imagen
    let unwrappedImage = currentImage
    var image = self.imageCache[unwrappedImage]
    let imageUrl = NSURL(string: marcas[indexPath.row].imagen)

    // reset reused cell image to placeholder
    cell.marcaImageView.image = UIImage(named: "")

    // async image
    if image == nil {

        let request: NSURLRequest = NSURLRequest(URL: …
Run Code Online (Sandbox Code Playgroud)

ios ios9 swift2

3
推荐指数
1
解决办法
4989
查看次数

在我删除它并重新启动我的应用程序后,核心数据是持久的

早上好,

我第一次在 Swift 2.2 中使用 CoreData。目前,我可以将对象添加到我的实体“项目”中,并且在按下“删除所有内容”按钮后我可以删除所有项目。这是正确的,但是当我删除所有对象然后重新启动我的应用程序时,在“删除所有内容”操作之前我仍然拥有相同的核心数据。

这就是我删除核心数据对象的方式

@IBAction func removeWishlist(sender: AnyObject) {
    deleteAllData("ItemsWishlist")
    getWishlist()
    self.tableView.reloadData()
}

func deleteAllData(entity: String) {

    let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
    let managedContext = appDelegate.managedObjectContext
    let fetchRequest = NSFetchRequest(entityName: entity)
    fetchRequest.returnsObjectsAsFaults = false

    do
    {
        let results = try managedContext.executeFetchRequest(fetchRequest)
        for managedObject in results
        {
            let managedObjectData:NSManagedObject = managedObject as! NSManagedObject
            managedContext.deleteObject(managedObjectData)
            print("Deleted")
        }

    } catch let error as NSError {
        print(error)
    }
}
Run Code Online (Sandbox Code Playgroud)

它正在工作,因为当我按下按钮时,列表是空的,但是当我重新启动应用程序时,它再次显示与我按下“清除”按钮之前相同的项目。

这是我的AppDelegate与核心数据部分:

// MARK: - Core Data …
Run Code Online (Sandbox Code Playgroud)

core-data ios swift swift2

3
推荐指数
1
解决办法
2189
查看次数