当前位置:编程学习 > wap >>

我有一段代码,在iphone 模拟器运行正常,但在macos 模拟器运行crash,请帮忙看下

SecKeyRef getPublicKeywithRawKey(NSString *peerNode,NSData *publicKey)

{
    
    OSStatus sanityCheck = noErr;
    SecKeyRef peerKeyRef = NULL;
    CFTypeRef persistPeer = NULL;
    CFDictionaryRef tmpDic;
    //LOGGING_FACILITY( peerName != nil, @"Peer name parameter is nil." );
    //LOGGING_FACILITY( publicKey != nil, @"Public key parameter is nil." );
    
    NSMutableDictionary * peerPublicKeyAttr = [[NSMutableDictionary alloc] init];
    
    [peerPublicKeyAttr setObject:(id)kSecClassKey forKey:(id)kSecClass];
    [peerPublicKeyAttr setObject:(id)kSecAttrKeyTypeRSA forKey:(id)kSecAttrKeyType];
    [peerPublicKeyAttr setObject:[peerNode dataUsingEncoding:NSUTF8StringEncoding] forKey:(id)kSecAttrApplicationTag];
    [peerPublicKeyAttr setObject:publicKey  forKey:(id)kSecValueData];
    [peerPublicKeyAttr setObject:[NSNumber numberWithBool:YES] forKey:(id)kSecReturnPersistentRef];
    tmpDic = (CFDictionaryRef)peerPublicKeyAttr;

     sanityCheck = SecItemAdd((CFDictionaryRef) peerPublicKeyAttr, (CFTypeRef *)&persistPeer);
}

问题是,
2012-04-13 15:58:12.649 macOS_RsaTest1[1502:403] -[NSConcreteMutableData _fastCharacterContents]: unrecognized selector sent to instance 0x7fe301a0a560
2012-04-13 15:58:12.651 macOS_RsaTest1[1502:403] -[NSConcreteMutableData _fastCharacterContents]: unrecognized selector sent to instance 0x7fe301a0a560

是在macos 中,我不能用 (CFDictionaryRef) peerPublicKeyAttr 这种方式吗? 请高手忙帮看下。 --------------------编程问答-------------------- 大牛帮忙看下哦!
补充:移动开发 ,  iPhone
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,