我正在尝试创建一个自定义UIView,它保存对自己的IBOutlets的引用.然后我想将这个自定义UIView放入另一个笔尖.
我在自定义UIView的awakeFromNib方法中做了一些额外的逻辑.不幸的是,当我尝试访问IBOutlets时awakeFromNib,它们是零.
这是设置:
UIView子类,CustomView..xib包含三个子视图的自定义文件UIView拖到视图上,然后将自定义类更改为CustomView.CustomViewIB 中的nib中的视图设置为自定义类CustomView并连接IBOutlets到视图,但它们仍然是零.CustomView并连接IBOutlets到文件的所有者,但它们仍然是零.IBOutlet UIView *view,然后补充说,作为一个子视图self中awakeFromNib,但还没有做任何事情.这是代码:
// CustomView.h
@interface CustomView : UIView
@property (nonatomic, retain) IBOutlet UITextField *textField;
@property (nonatomic, retain) IBOutlet UIView *subview1;
@property (nonatomic, retain) IBOutlet UIView *subview2;
// CustomView.m
@implementation CustomView
@synthesize textField, subview1, subview2;
- (id)initWithFrame:(CGRect)frame { …Run Code Online (Sandbox Code Playgroud) 我已经创建了一对密钥SecKeyGeneratePair.我现在想将公钥传递给服务器,但我不确定如何继续.
我有一个功能getPublicKeyBits(取自Apple的CryptoExercise),但我真的不知道如何处理原始NSData.这是功能:
- (NSData *)getPublicKeyBits {
OSStatus sanityCheck = noErr;
NSData* publicKeyBits = nil;
NSData* publicTag = [[NSData alloc] initWithBytes:publicKeyIdentifier length:sizeof(publicKeyIdentifier)];
CFDataRef cfresult = NULL;
NSMutableDictionary * queryPublicKey = [[NSMutableDictionary alloc] init];
// Set the public key query dictionary.
[queryPublicKey setObject:(__bridge id)kSecClassKey forKey:(__bridge id)kSecClass];
[queryPublicKey setObject:publicTag forKey:(__bridge id)kSecAttrApplicationTag];
[queryPublicKey setObject:(__bridge id)kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType];
[queryPublicKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnData];
// Get the key bits.
sanityCheck = SecItemCopyMatching((__bridge CFDictionaryRef)queryPublicKey, (CFTypeRef*)&cfresult);
if (sanityCheck != noErr)
{
publicKeyBits …Run Code Online (Sandbox Code Playgroud)