سؤال

I am trying this Using the Keychain to store passwords on iOS with storybored to store user email and password for login.

In my m file:

....
....
#import "KeychainItemWrapper.m"
....
....
KeychainItemWrapper* keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"KeychainTest" accessGroup:nil];
        [keychain setObject:kSecAttrAccessibleWhenUnlocked forKey:kSecAttrAccessible];

        NSLog(@"%@, %@", [keychain objectForKey:kSecAttrAccount], [keychain objectForKey:kSecValueData]);

        [keychain setObject:@"example@email.com" forKey:kSecAttrAccount];
        [keychain setObject:@"MySuperSecretPassword" forKey:kSecValueData];

        NSLog(@"%@, %@", [keychain objectForKey:kSecAttrAccount], [keychain objectForKey:kSecValueData]);

but I am getting the following errors:

Implicit conversion of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast

enter image description here

هل كانت مفيدة؟

المحلول

I already answered this in your other post. Is there an Android sharedpreferences equivalent in iOS to save credentials (Username and Password)?

I'll repost it here:

This happens because you are probably using "ARC". Are you? If so, you can set a flag to ignore ARC for that specific file. Select your project, Select your target, select Build Phases and expand the "Compile Sources" drop down. Look for KeychainItemWrapper (or whatever you call your keychain file) and set this flag. -fno-objc-arc

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top