Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
unidocs-uni-app-x-zh
提交
6a36b982
U
unidocs-uni-app-x-zh
项目概览
DCloud
/
unidocs-uni-app-x-zh
通知
200
Star
3
Fork
46
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
14
列表
看板
标记
里程碑
合并请求
16
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
unidocs-uni-app-x-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
14
Issue
14
列表
看板
标记
里程碑
合并请求
16
合并请求
16
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
6a36b982
编写于
5月 30, 2024
作者:
taohebin@dcloud.io
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update uts-for-ios.md
上级
dda49b06
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
0 deletion
+24
-0
docs/plugin/uts-for-ios.md
docs/plugin/uts-for-ios.md
+24
-0
未找到文件。
docs/plugin/uts-for-ios.md
浏览文件 @
6a36b982
...
...
@@ -819,6 +819,30 @@ class TestB {
```
#### 5.1.15 指针操作
在Swift操作指针,需要用到
`&`
操作符隐式转换得到
`UnsafePointer`
类型,UTS中提供了
`UTSiOS.getPointer()`
来表示
`&`
符号。
以获取字符串MD5为例,如下
```
ts
private
convertToMD5
(
param
:
string
)
:
string
{
const
strData
=
param
.
data
(
using
=
String
.
Encoding
.
utf8
)
!
let
digest
=
new
Array
<
UInt8
>
(
repeating
=
0
,
count
=
new
Int
(
CC_MD5_DIGEST_LENGTH
))
strData
.
withUnsafeBytes
((
body
:
UnsafeRawBufferPointer
)
=>
{
CC_MD5
(
body
.
baseAddress
,
new
UInt32
(
strData
.
count
),
UTSiOS
.
getPointer
(
digest
))
})
let
md5String
=
""
digest
.
forEach
((
byte
:
UInt8
)
=>
{
md5String
+=
new
String
(
format
=
"
%02x
"
,
new
UInt8
(
byte
))
})
return
md5String
}
```
其中
`UTSiOS.getPointer(digest)`
编译后会变成
`&digest`
## 6 常见问题(持续更新)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录