// 키체인 아이템 생성
NSData* secret = [@"top secret" dataWithEncoding: NSUTF8StringEncoding];
NSDictionary* query = @ {
	(id) kSecClass: (id)kSecClassGenericPassword,
	(id) kSecAttrService: @"myservice",
	(id) kSecAttrAccount: @"account name here",
	(id) kSecValueData: secret,
};
OSStatus status = SecItemAdd((CFDictionaryRef)query, NULL);

// 룩업
NSDictionary* query = @ {
	(id) kSecClass: (id)kSecClassGenericPassword,
	(id) kSecAttrService: @"myservice",
	(id) kSecAttrAccount: @"account name here",
	(id) kSecReturnData: @YES,
};
NSData *data = NULL
OSStatus status = SecItemCopyMatching((CFDictionaryRef) query, (CFTypeRef*) &data);

NSDictionary* query = @ {
	(id) kSecClass: (id)kSecClassGenericPassword,
	(id) kSecAttrService: @"myservice",
	(id) kSecAttrAccount: @"account name here",
};
NSDictionary* changes = @{...};
// 업데이트 - 삭제후 다시 삽입하지 말라
OSStatus SecItemUpdate((CFDictionaryRef) query, (CFDictionaryRef) changes);
// 삭제
OSStatus status = SecItemDelete((CFDictionaryRef) query);

NSData* password = nil;

if (SecItemCopyMatching(..., &password) == noErr) {
	if (패스워드가 동작한다.) {
		great!
	} else {
		password = 다른 패스워드;
		if (바뀐 패스워드가 괜찮다) {
			SecItemUpdate(...);
		}
	}
} else {
		password = get from user;
		if (passwork works) {
			SetItemAdd(...);
		}
	}