小编ap1*_*123的帖子

将数据迁移到应用程序组会禁用 iCloud 同步

我正在向我现有的应用程序添加 Today Extension。我添加了一个应用程序组并使用这篇文章成功地将我的核心数据的数据迁移到了应用程序组的商店。我的应用程序同时使用 NSPersistentCloudKitContainer(当 iCloud 开启时)和一个 NSPersistentContainer(iCloud 关闭时)。虽然两个容器中的数据都成功迁移,但在使用 NSPersistentCloudKitContainer 时,我无法再在我的设备之间同步。在控制台中,我收到以下两个错误:

CoreData: 错误: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(837): : 无法为商店设置 CloudKit 集成: (URL: file://path/name.sqlite)

错误域=NSCocoaErrorDomain 代码=134060 “发生核心数据错误。” UserInfo={NSLocalizedFailureReason=镜像委托无法初始化,因为它的存储已从协调器中删除。}

第一条错误消息的路径是切换到 App Groups 之前的 oldURL 的路径。所以我相信我只需要告诉 iCloud 不要尝试在该商店位置集成 CloudKit 并使用应用程序组的商店位置。

但我不知道如何做到这一点。任何人都可以帮忙吗?

核心数据代码:

class CoreDataManager {
    static let sharedManager = CoreDataManager()
    private init() {}

    lazy var persistentContainer: NSPersistentContainer = {
        var useCloudSync = UserDefaults.standard.bool(forKey: "useCloudSync")

        //Get the correct container
        let containerToUse: NSPersistentContainer?
        if useCloudSync {
           containerToUse = NSPersistentCloudKitContainer(name: "App")
        } else {
            containerToUse …
Run Code Online (Sandbox Code Playgroud)

xcode core-data swift ios-app-group nspersistentcloudkitcontainer

12
推荐指数
1
解决办法
1087
查看次数

Xcode 10错误:链接器命令失败,退出代码为1

我刚刚将Xcode更新为Xcode 10,现在我的项目无法运行,我收到错误消息:

ld: library not found for -lstdc++.6 clang: error: linker command failed with exit code 1 (use -v to see invocation)

我不知道这意味着什么,以及如何解决它.我试着谷歌搜索到答案,并没有提出任何问题.我怎样才能解决这个问题?

xcode swift xcode10

9
推荐指数
2
解决办法
1万
查看次数

强制 NSPersistentContainer 更改核心数据

我刚刚添加了一个选项,供用户在我的应用程序中切换云同步,我保存用户是否要在“useCloudSync”下的 UserDefaults 中使用 iCloud 同步。当应用程序运行时,我加载我的persistentContainer:

class CoreDataManager {
    static let sharedManager = CoreDataManager()
    private init() {}

    lazy var persistentContainer: NSPersistentContainer = {
        var useCloudSync = UserDefaults.standard.bool(forKey: "useCloudSync")

        let containerToUse: NSPersistentContainer?
        if useCloudSync {
           containerToUse = NSPersistentCloudKitContainer(name: "App")
        } else {
            containerToUse = NSPersistentContainer(name: "App")
            let description = containerToUse!.persistentStoreDescriptions.first
            description?.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
      }

        guard let container = containerToUse, let description = container.persistentStoreDescriptions.first else {
            fatalError("Hey Listen! ###\(#function): Failed to retrieve a persistent store description.")
        }
        description.setOption(true as NSNumber, forKey: …
Run Code Online (Sandbox Code Playgroud)

xcode core-data icloud swift nspersistentcloudkitcontainer

7
推荐指数
1
解决办法
411
查看次数

向 iCloud 生产发布新的核心数据架构

我在应用程序商店中有一个应用程序,我正在进行轻量级迁移(添加新属性和新实体,而不是删除任何内容)。通过广泛的研究,我知道我需要为本地版本的数据模型添加当前核心数据模型的新版本。任何更新应用程序且仅使用本地数据的人都会自动迁移。

但是,我无法找到有关更新 iCloud 架构(来自 icloud.developer.apple.com)时发生的情况的任何信息。主要是,我担心使用旧版本应用程序并使用 iCloud 的用户。当我更新 iCloud 网站中的架构时,旧版本应用程序上的用户是否会丢失当前数据或无法同步其数据,因为他们的本地架构与 iCloud 架构不同?

另外,我正在使用NSPersistentCloudKitContainerCloudKit 来同步核心数据。

非常感谢任何帮助,因为我不想弄乱任何人的数据!

core-data core-data-migration icloud cloudkit nspersistentcloudkitcontainer

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

通用链接 将 JSON 上传到 HTTPS 服务器

我正在尝试在我的 IOS 应用程序中实现通用链接。我有苹果文档并正在按照步骤操作,但在将“apple-app-site-association”文件上传到 HTTPS Web 服务器的根目录时遇到问题。我正在使用 Wix.com 构建我的网站,并使用 Google Admin 作为网站域。我不知道在哪里上传这个文件,我查遍了 Wix 文档,但一无所获。这是 Wix 的问题吗?或者我还缺少其他东西吗?


苹果文档:https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html

维克斯:https: //www.wix.com

https json ios velo

5
推荐指数
0
解决办法
303
查看次数

Venmo 深度链接

我一直在研究如何使用 venmo 深度链接方案,并尝试根据用户的用户名打开用户的帐户。我在互联网上查找了所有内容,最接近的是这篇博客文章。博客文章中的人非常接近实现我想要的目标,但我仍然无法弄清楚。我尝试多次更改“venmo://users”,试图用用户名打开个人资料,但没有任何效果。我怎样才能做到这一点?

先感谢您

deep-linking venmo swift

5
推荐指数
1
解决办法
3040
查看次数

为 Xcode Pods 文件夹添加 Git Ignore 不起作用

我使用以下命令在我的 Xcode 项目中添加了一个 git ignore 文件:touch .gitignore然后open .gitignore将其复制并粘贴到git ignore 内容中(并取消注释该行的Pods/行)并保存文件。

但是当我仍然尝试在 Xcode 中提交(已经提交了很多次)时,Pods 文件仍然存在并且已经检查提交。

如何不检查我的 Pod 文件并使 git ignore 与我的 Xcode 项目一起工作?

git xcode ios cocoapods

5
推荐指数
1
解决办法
2465
查看次数

如何将Core Data的数据迁移到App Group的数据

我刚刚App Groups使用此StackOverFlow 帖子添加到我的应用程序中。不幸的是,由于defaultDirectoryURL正在发生变化,我无法获取在使用应用程序组目录之前制作的任何旧数据。我知道数据仍然存在,因为当我切换回使用常规NSPersistentContainer而不是 时GroupedPersistentContainer,我可以获取数据。

如何将旧数据迁移到我正在获取应用组数据的位置?

核心数据代码:

class CoreDataManager {
    static let sharedManager = CoreDataManager()
    private init() {}

    lazy var persistentContainer: NSPersistentContainer = {
        var useCloudSync = UserDefaults.standard.bool(forKey: "useCloudSync")

        let containerToUse: NSPersistentContainer?
        if useCloudSync {
           containerToUse = NSPersistentCloudKitContainer(name: "App")
        } else {
            containerToUse = GroupedPersistentContainer(name: "App")
            let description = containerToUse!.persistentStoreDescriptions.first
            description?.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
      }

        guard let container = containerToUse, let description = container.persistentStoreDescriptions.first else {
            fatalError("Hey Listen! ###\(#function): Failed …
Run Code Online (Sandbox Code Playgroud)

migration core-data swift ios-app-group nspersistentcontainer

5
推荐指数
0
解决办法
1673
查看次数

在保持Tabbar的同时在AppDelagate中打开ViewController

在我的Xcode项目中,当用户点击通知时,我想首先将它们发送到我的tabBar中的某个项目,然后我想实例化一个视图控制器并将一个对象发送到该视图控制器.我有代码将它们发送到我想要的tabBar,但我不知道如何将它们实例化到视图控制器,同时保持tabBar和导航栏连接到视图控制器.所有答案都要求您更改根视图控制器,这会使我在调用视图控制器时失去与tabBar和导航栏的连接.

真实生活示例:用户收到Instagram通知,说"John开始关注你" - >用户点击通知 - > Instagram打开并显示通知标签 - >快速将用户发送到"John"个人资料,当用户按下后退按钮时,它将它们发送回通知选项卡

应该知道:我之前要去某个标签的原因是为了获得该标签的导航控制器,因为我将要使用的视图控制器没有.

这是我将用户发送到"通知"标签的工作代码(为了更好地理解,我添加了评论以像Instagram示例一样):

if let tabbarController = self.window!.rootViewController as? UITabBarController {
    tabbarController.selectedViewController = tabbarController.viewControllers?[3] //goes to notifications tab
    if type == "follow" { //someone started following current user                            
        //send to user's profile and send the user's id so the app can find all the information of the user                    
    }
}
Run Code Online (Sandbox Code Playgroud)

xcode uiviewcontroller ios appdelegate swift

2
推荐指数
1
解决办法
1103
查看次数

仅在某些单元格上允许刷卡

我有一个tableview,它将根据所按的按钮更改其单元格。在第一个表格视图中,我希望仅在按下按钮时才能滑动单元格。如果不是,则应禁用滑动功能。按下按钮后,表格视图即可滑动并显示我想要的操作。但是,当未按下按钮时,单元格仍然可以通过“删除”操作来滑动。如果单元格标签包含当前用户名,我也不希望可滑动行。

我在底部添加了用于tableview的代码。我该如何解决?

第一张表的代码:

 override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
                let cell = tableView.cellForRow(at: indexPath) as! DetailsCell
                let detailsAction = UITableViewRowAction(style: UITableViewRowActionStyle.default, title: "Details") { (action , indexPath) -> Void in
                        if isCharacterButtonPressed == true { //if button is pressed
                            if cell.label != currentUser.name{
                                let viewController = self.storyboard?.instantiateViewController(withIdentifier: "SeeDetails") as! DetailsVC
                                viewController.person = cell.person            
        self.navigationController?.pushViewController(viewController, animated: true)
                            } else {
                              return .none
                             }
                            return [detailsAction] //makes cell swipe-able
                        } else { //if button is not pressed …
Run Code Online (Sandbox Code Playgroud)

uitableview swipe ios swift

0
推荐指数
1
解决办法
708
查看次数