在面向 Mac App Store 的 macOS 应用程序中,是否允许使用 sysctlbyname 获取当前 Mac 模型?

In a macOS application targeted for the Mac App Store, is the use of sysctlbyname allowed to get the current Mac model?

我在我的 macOS 应用程序中使用这个 Objective-C 代码:

#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/sysctl.h>

- (NSString *)machineModel {

size_t len = 0;
sysctlbyname("hw.model", NULL, &len, NULL, 0);

if (len)
{
    char *model = malloc(len*sizeof(char));
    sysctlbyname("hw.model", model, &len, NULL, 0);
    NSString *model_ns = [NSString stringWithUTF8String:model];
    free(model);
    return model_ns;
}

    return @"Just an Apple Computer"; //incase model name can't be read
}

目前,我的 none 个应用已因此被拒绝。这段代码有没有可能给我带来以后的提交问题?

非常感谢您的帮助。

For the moment, none of my apps have been rejected for this reason. Is it possible that this code can bring me to submission problems in the future ?

您说得对,据我们所知,sysctlbyname 目前可供 MAS 应用免费使用以获取信息——商店中还有其他应用在使用它。

Apple 会更改规则吗?谁知道呢,可能连 Apple 也不行。

但是,如果某些软件开始将收集到的信息用于恶意目的,则预计会减少此功能的使用。黑客,从广告商,一直到政客,都是我们经常得不到好东西的原因;-(

截至 2020 年 8 月,我使用以下方式提交:

(swift 5.x)

 let result = sysctlbyname(".....