gpt4 book ai didi

ios - 在MFMailCompose中显示iPhone型号

转载 作者:行者123 更新时间:2023-12-01 16:34:58 25 4
gpt4 key购买 nike

我已经阅读了Identify new iPhone model on xcode (5, 5c, 5s)这个问题的答案,并希望将其作为NSString添加到我的MFMailCompose中。我尝试使用这种方法,但是没有任何运气。有人请帮助我。

抱歉,我是Xcode的新手。

                NSString *iOS           = [[UIDevice currentDevice] systemVersion];
NSString *model = [[UIDevice currentDevice] model];
NSString *appVersionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
NSString *name = [[UIDevice currentDevice] name];
NSString *appID=@" ";
NSString *appStoreURL =[NSString stringWithFormat:@"https://itunes.apple.com/us/app/scanmarks/id926114469?ls=1&mt=8", appID];
NSString *body = [NSString stringWithFormat:@"I need help with\n\n\n----------\n Name: %@\nDevice: %@ (%@)\n Scanmarks Version: %@\n",name,model,iOS,appVersionString];

当前显示:

我希望它像Tweetbot一样显示iPhone设备模型

我添加了建议,现在有了这个:

最佳答案

使用您在问题中添加的链接,如果您只想让它说iPhone平台,则只需使用其答案的这一部分:

size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];

free(machine);

它将转换为iPhone7,2等。只需将 NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];字符串“platform”传递到您的消息正文中

如果要将其转换为任意字符串,则在其他部分起作用时。这是您唯一使用答案的另一部分和所有转化的方法:
NSString *convertPlatformToString = [self platformType:platform]);

放入邮件示例:
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];

free(machine);

NSString *body = [NSString stringWithFormat:@"Platform is %@", platform];

关于ios - 在MFMailCompose中显示iPhone型号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29062773/

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