小编Gra*_*Fox的帖子

Swift 3中的UnsafePointer <UInt8>初始化程序

我有一个收据验证类,自Swift 3发布以来已弃用.我解决了一些问题,但我还有很多......

这是我使用的GitHub源代码:https://gist.github.com/baileysh9/4386ea92b047d97c7285#file-parsing_productids-swifthttps://gist.github.com/baileysh9/eddcba49d544635b3cf5

  1. 第一个错误:

        var p = UnsafePointer<UInt8>(data.bytes)
    
    Run Code Online (Sandbox Code Playgroud)

编译器抛出:无法使用类型UnsafeRawPointer的参数列表调用类型UnsafePointer(UInt8)的初始化程序

  1. 第二个错误

    while (ptr < end)
    
    Run Code Online (Sandbox Code Playgroud)

二进制运算符<不能应用于两个UnsafePointer(UInt8)操作数

非常感谢你提前:)

编辑

感谢LinShiwei的回答,我找到了UnsafePointer声明的解决方案.它编译但尚未测试(因为其他错误避免我测试):

 func getProductIdFromReceipt(_ data:Data) -> String?
{
  let tempData: NSMutableData = NSMutableData(length: 26)!
  data.withUnsafeBytes {
        tempData.replaceBytes(in: NSMakeRange(0, data.count), withBytes: $0)
    }

    var p: UnsafePointer? = tempData.bytes.assumingMemoryBound(to: UInt8.self)
Run Code Online (Sandbox Code Playgroud)

unsafe-pointers ios swift3

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

使用未获得的标识符FIRMessaging

在我的iOS Swift应用程序中集成Firebase Notification新API时,我遇到了一个奇怪的问题.从Firebase网络平台发送推送通知时遇到一些困难.我的证书没问题,因为我用快速的PHP脚本测试它,以便向我的手机发送测试通知.

在这篇文章中:https://stackoverflow.com/a/37467793/5082848,据说在AppDelegate中添加

func applicationDidBecomeActive(application: UIApplication) {
    FIRMessaging.messaging().connectWithCompletion { error in
        print(error)
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,FIRMessaging未知,而我的podfile正确包含Firebase/Messaging.以下是pod安装后终端返回的内容:

使用Firebase(3.3.0)

使用FirebaseAnalytics(3.2.1)

使用FirebaseInstanceID(1.0.7)

使用GoogleInterchangeUtilities(1.2.1)

使用GoogleSymbolUtilities(1.1.1)

使用GoogleUtilities(1.3.1)

你有什么线索吗?非常感谢

ios firebase swift firebase-notifications

13
推荐指数
3
解决办法
8781
查看次数

Firebase Dynamic Link打开特定活动

我在iOS应用上实现了Firebase Dynamic链接(太棒了!),现在在Android上执行相同的工作。我设法通过单击动态URL来启动我的Android应用程序,但是我无法在启动器活动之外的其他活动上打开它。

这是我的manifest.xml文件:

    <activity android:name=".Activity.SplashActivity"
        android:theme="@style/SplashTheme"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".Activity.RouteListActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <data android:host="mywebsite.com" android:scheme="http"/>
            <data android:host="mywebsite.com" android:scheme="https"/>
            <data
                android:host="myapp.app.goo.gl/"
                android:scheme="https" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

当我单击URL时,浏览器打开并重定向到我的应用程序,但按预期在SplashActivity而不是RouteListActivity上打开。

我想念什么吗?

谢谢

android deep-linking firebase firebase-dynamic-links

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

无法使用户定义的运行时属性工作

我真的希望能够使用xcode Storyboard中的"用户定义的运行时属性"来通过容器视图构建一个漂亮的弹出窗口.不幸的是,我无法使它工作,无法弄清楚为什么!

我找到了很多主题(例如:是否可以从界面构建器设置UIView边框属性?)处理它但这对我不起作用......!

这是containerView嵌入UIView的属性检查器(我也尝试实现到containerView UIView也没有成功).

在此输入图像描述

我添加了一个扩展来按预期将UIColor转换为CGColor:

extension CALayer {
var borderUIColor: UIColor {
    set {
        self.borderColor = newValue.CGColor
    }

    get {
        return UIColor(CGColor: self.borderColor!)
    }
}
Run Code Online (Sandbox Code Playgroud)

}

有人能想到缺少的东西吗?

非常感谢您提前;)

uiview ios xcode-storyboard swift

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