我使用的是第三方庫在iOS項目,我的工作,我到一個警告,留在這個項目上,即在這行代碼多字符的字符序列
[NSNumber numberWithUnsignedLongLong:'oaut']
而且警告
Multi-character character constant
我吸在C,所以我不知道如何解決這個問題,但我敢肯定的解決方法是比較容易的。幫幫我?
編輯:更多的上下文。
@implementation MPOAuthCredentialConcreteStore (KeychainAdditions)
- (void)addToKeychainUsingName:(NSString *)inName andValue:(NSString *)inValue {
NSString *serverName = [self.baseURL host];
NSString *securityDomain = [self.authenticationURL host];
// NSString *itemID = [NSString stringWithFormat:@"%@.oauth.%@", [[NSBundle mainBundle] bundleIdentifier], inName];
NSDictionary *searchDictionary = nil;
NSDictionary *keychainItemAttributeDictionary = [NSDictionary dictionaryWithObjectsAndKeys: (id)kSecClassInternetPassword, kSecClass,
securityDomain, kSecAttrSecurityDomain,
serverName, kSecAttrServer,
inName, kSecAttrAccount,
kSecAttrAuthenticationTypeDefault, kSecAttrAuthenticationType,
[NSNumber numberWithUnsignedLongLong:"oaut"], kSecAttrType,
[inValue dataUsingEncoding:NSUTF8StringEncoding], kSecValueData,
nil];
if ([self findValueFromKeychainUsingName:inName returningItem:&searchDictionary]) {
NSMutableDictionary *updateDictionary = [keychainItemAttributeDictionary mutableCopy];
[updateDictionary removeObjectForKey:(id)kSecClass];
SecItemUpdate((CFDictionaryRef)keychainItemAttributeDictionary, (CFDictionaryRef)updateDictionary);
[updateDictionary release];
} else {
OSStatus success = SecItemAdd((CFDictionaryRef)keychainItemAttributeDictionary, NULL);
if (success == errSecNotAvailable) {
[NSException raise:@"Keychain Not Available" format:@"Keychain Access Not Currently Available"];
} else if (success == errSecDuplicateItem) {
[NSException raise:@"Keychain duplicate item exception" format:@"Item already exists for %@", keychainItemAttributeDictionary];
}
}
}
編輯2:他們正試圖通過創造來滿足這個要求是NSNumber的:
@constant kSecAttrType Specifies a dictionary key whose value is the item's
type attribute. You use this key to set or get a value of type
CFNumberRef that represents the item's type. This number is the
unsigned integer representation of a four-character code (e.g.,
'aTyp').
看起來像一個錯字,因爲'oaut'絕對不是一個無符號長整數。那裏應該有什麼號碼? – MechEthan
yAak:我認爲它應該有它,這是瘋狂的一部分。用更多的上下文更新後。 – refulgentis
考慮到這一點,我記得多字符字符常量在C中是可能的(最多四個字符,IIRC)。也許'oaut'真的是一個這樣的角色,被用作int並被提升爲無符號long long。 'oaut'是代碼中使用的「oauth」的第一個字符。顯然CodeWarrior接受了這樣的代碼。 –