gpt4 book ai didi

iphone - 在 Objective-C 中将 unsigned char * 转换为 int *

转载 作者:行者123 更新时间:2023-12-03 20:24:46 25 4
gpt4 key购买 nike

我正在尝试在 iPhone 上的 Objective-C 中将 unsigned char* 转换为 int * 。有没有可以帮助转换的API?

这是我最好的尝试:

-(BOOL)MyFunc:Version:(int *)nVer
{
unsigned char * uszVerSize;
//trying to assign string to int
nVer = uszVerSize[0] ;
}

最佳答案

亲爱的主,我认为您的问题比上述问题更大。

您需要将字符转换为 int 并返回。

return [[NSNumber numberWithUnsignedChar:uszVerSize] intValue];

您还应该了解指针以及整数和字符在内存中的差异。您不能只将指向 char 的指针分配给指向 int 的指针。

关于iphone - 在 Objective-C 中将 unsigned char * 转换为 int *,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1839577/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com