I am trying to write some data that is generated from NSMutableArray, like this
// set up keychain so I can write to it⦠or read if needed (specially for testing) KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"KeychainTest" accessGroup:nil]; [keychain setObject:(__bridge id)(kSecAttrAccessibleWhenUnlocked) forKey:(__bridge id)(kSecAttrAccessible)]; //write to keychain NSData *parsedRemoteSitesData = [NSKeyedArchiver archivedDataWithRootObject:parsedRemoteSitesMutableArray]; // converts MutableArray to NSData [keychain setObject:parsedRemoteSitesData forKey:(__bridge id)(kSecValueData)]; pass data to keychain
my application is broken to the last line where I try to pass NSData to the keychain, this is the error it gives.
** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableData dataUsingEncoding:]: unrecognized selector sent to instance
I think this means that I did not encode my NSData when passing the array, but I'm not sure. I was hoping someone could tell me or provide sample code to fix this.
Any help would be greatly appreciated.
source share