Q:

Keychain warning in XCode

here is my code:
    //Set
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"Animex" accessGroup:nil];
[keychain setObject:username forKey:kSecValueData];
[keychain setObject:password forKey:kSecAttrAccount];

[keychain release];

It works perfectly, but I get a warning:
"passing argument 2 of 'set object:forkey' discards qualifiers from pointer target type.

What does it mean?
How to solve?

A:

Cast the parameter to id.
[keychain setObject:username forKey:(id)kSecValueData];
[keychain setObject:password forKey:(id)kSecAttrAccount];

kSecValueData and kSecAttrAccount are CFTypeRef and setObject:forKey: expects an id.
CFTypeRef is defined as:
typedef const void * CFTypeRef;

It's the fact that it's a const that's giving you this warning.

