小编Ric*_*ppz的帖子

在iOS Swift中将NSDate转换为String

我试图将a转换NSDate为a String然后更改格式.但是当我传递NSDateString它时会产生空白.

 let formatter = DateFormatter()
 let myString = (String(describing: date))
 formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
 let yourDate: Date? = formatter.date(from: myString)
 formatter.dateFormat = "dd-MMM-yyyy"
 print(yourDate)
Run Code Online (Sandbox Code Playgroud)

nsdateformatter ios swift swift3

61
推荐指数
5
解决办法
9万
查看次数

iCloud设置和配置

我正在尝试在我的iOS应用程序中设置iCloud,我已经完成了以下操作:

  1. 删除了mac上的所有旧证书.
  2. 在开发者控制台中将iCloud添加到应用程序 - 创建了新容器并添加到应用程序
  3. 重做dev配置并下载
  4. 安装规定
  5. 在应用程序中添加了iCloud Entitlement

这就是出错的地方......

我无法让应用程序再次运行,应用程序正在构建但我收到错误说:

应用程序的代码签名权利文件中指定的权利与您的供应配置文件中指定的权利不匹配.

(0xE8008016).

有任何想法吗??

更新:我已经设法能够运行应用程序以使所有程序编程并放置到位,一切都设置为iTunes Connect端,所有规定都有效且同步.

现在我在验证期间遇到错误...

有4个:无效的代码签名权利.您的应用程序包的签名包含iOS不支持的代码签名权利.具体来说,Payload中的密钥"com.apple.developer.icloud-container-identifiers"-------不受支持

其他3个与其他容器相似!

xcode certificate icloud ios7

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

在Swift 4中更新具有多种类型的标签

我有一个API,有时会以Int形式返回JSON中的特定键,而有时它会以String形式返回相同的键,我通过创建一个枚举IntOrString来解决此问题。现在的问题是,当我调用API更新这些特定键的标签时,类型是错误的。

然后我得到错误无法将Double类型转换为DoubleOrString类型

enum DoubleOrString: Codable {

    case double(Double)
    case string(String)

    init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        do {
            self = try .double(container.decode(Double.self))
        } catch DecodingError.typeMismatch {
            do {
                self = try .string(container.decode(String.self))
            } catch DecodingError.typeMismatch {
                throw DecodingError.typeMismatch(
                    DoubleOrString.self,
                    DecodingError.Context(
                        codingPath: decoder.codingPath,
                        debugDescription: "Encoded payload conflicts with expected type, (Double or String)"
                    )
                )
            }
        }
    }

    func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()
        switch self {
        case .double(let double):
            try container.encode(double)
        case …
Run Code Online (Sandbox Code Playgroud)

ios swift

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

独立 WatchOS6 应用程序的 APNS 失败

设置一个新的独立的 WatchOS6 应用程序后,现在支持推送通知,让设备向用户请求推送通知并捕获推送令牌。我无法让我的服务器发送推送通知。

在我的 NodeJS 服务器上设置了所有正确的凭据和 P8 后,我尝试将消息推送到设备......这一直是错误:

状态 400 - DeviceTokenNotForTopic- 根据 Apple 的文档,这意味着主题(应用程序的 BundleId)是错误的。但在这种情况下并非如此。

尝试了 2 个不同的 NPM 包(用于消除)

https://www.npmjs.com/package/node-pushnotifications

https://www.npmjs.com/package/apn

两者都为我提供了相同的问题。

有没有人成功地使用 APNs 完成了一个独立的 WatchOS 应用程序?我错过了什么

———

更新

为了测试节点服务,又做了2个测试:

  1. 这次创建了一个新的应用程序,iOS,使用相同的 Bundle Identifier,使用 pushToken 并发送消息服务成功

  2. 创建了一个新应用程序,另一个 watchOS,具有不同的捆绑标识符,这再次被拒绝,但 APNs 是针对同一DeviceTokenNotForTopic问题的。

要测试生产,目前唯一的方法是提交到应用商店进行 App Store 审核。TestFlight 选项目前不适用于 Watch,并且无法.ipa手动安装生产临时产品。一旦它在商店里,我将继续进行进一步的测试。

node.js swift ios13 watchos-6

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

如何使用多个目标使用同名的不同资产

我正在尝试构建具有多个目标的应用,每个目标应具有不同的资产版本。业务需求是拥有相同的应用程序,但拥有不同的品牌资产。我不想手动复制和粘贴项目并更改图标,因为这样效率不高。

例如,我logo在资产目录中有一个,目标X目标Y都需要查看资产,但是两个目标都需要查看资产的不同版本。

xcode ios swift

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

Cocoa CALayer 不显示 NSImage

在 CALayer 中显示 NSImage 时出现问题

\n\n
 init(image: NSImage) {\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0self.image = image\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0super.init(frame: .zero)\n }\n\n required init(coder aDecoder: NSCoder) {\n\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0fatalError("init(coder:) has not been implemented")\n }\n\n override func viewWillDraw() {\n     super.viewWillDraw()\n     animationLayer.contentsGravity = kCAGravityResizeAspect\n     animationLayer.frame = CGRect(x: 0, y: 0, width: frame.size.width, height: frame.size.height)\n     animationLayer.contents = image.cgImage\n     animationLayer.masksToBounds = true\n     animationLayer.backgroundColor = NSColor.blue.cgColor\n\n     wantsLayer = true\n     layer?.addSublayer(animationLayer)\n }\n
Run Code Online (Sandbox Code Playgroud)\n\n

设置为蓝色的 CALayerbackgroundColor渲染得很好,但 CALayer 则NSImage不然。确认NSImage包含所需的图像并在类初始化时设置。

\n\n

在 iOS 框架内开发了相同的内容后,我很难看出其中的差异。

\n

macos cocoa calayer nsimage swift3

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