我正在尝试检查 iPhone 上是否存在配置文件,我找到了以下关于如何操作的教程:http: //alex.tapmania.org/2011/09/check_conf_prof_is_installed_ios.html
对我来说,它转化为以下代码:
NSString * certPath = [[NSBundle mainBundle] pathForResource:@"certificate" ofType:@"mobileconfig"];
SecTrustRef trust;
NSData * certData = [NSData dataWithContentsOfFile:certPath];
SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef) certData);
SecPolicyRef policy = SecPolicyCreateBasicX509();
OSStatus err = SecTrustCreateWithCertificates((__bridge CFArrayRef) [NSArray arrayWithObject:(__bridge id)cert],policy, &trust);
SecTrustResultType trustResult = -1;
err = SecTrustEvaluate(trust, &trustResult);
if (trustResult ==4) {
label.text=@"Profile installed";
}
else{
label.text=@"Profile not installed";
}
应用程序在以下行崩溃:
OSStatus err = SecTrustCreateWithCertificates((__bridge CFArrayRef) [NSArray arrayWithObject:(__bridge id)cert],policy, &trust);
我还注意到在这个阶段cert
没有分配任何内存。
怎么了?这是正确的程序吗?如果没有,还有其他更有益的教程吗?
谢谢!