小编erc*_*cgh的帖子

如何在ios应用程序中打开app store?

我正在使用此代码来评估ios应用程序中的应用程序.

let appLink = "https://itunes.apple.com/us/app/[name of the app]/id[idnumber]?mt=8"
let url = URL(string: appLink)
UIApplication.shared.openURL(url!)
Run Code Online (Sandbox Code Playgroud)

问题是Safari说"页面地址无效"

有没有办法使它工作?我正在使用xcode 9和swift 4

ios swift

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

Swift - 使用UnsafePointer 传递变量和传递变量地址之间的区别?

最近我试图查看变量的地址,我有这个问题。

var age: Int = 5

withUnsafePointer(to: age) {
    print($0) // 0x00007ffee3362750
    print($0.pointee) // 5
}

withUnsafePointer(to: &age) {
    print($0) // 0x000000010d226330
    print($0.pointee) // 5
}
Run Code Online (Sandbox Code Playgroud)

为什么它显示不同的内存地址以及为什么它显示相同的值pointee?

var strarr = [1, 2]

withUnsafePointer(to: strarr[0]) {
    print("\($0)") // 0x00007ffee3362750
    print("\($0.pointee)") // 1
}

withUnsafePointer(to: strarr[1]) {
    print("\($0)") // 0x00007ffee3362750
    print("\($0.pointee)") // 2
}

withUnsafePointer(to: &strarr[0]) {
    print("\($0)") // 0x0000600002755760
    print("\($0.pointee)") // 1
}

withUnsafePointer(to: &strarr[1]) {
    print("\($0)") // 0x0000600002755768
    print("\($0.pointee)") // 2
}
Run Code Online (Sandbox Code Playgroud)

对于数组,为什么当我不传递变量的地址时,它为索引 1 和 2 显示相同的内存地址?为什么当我传递内存地址时,它为索引 1 …

ios swift

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

标签 统计

ios ×2

swift ×2