Is there any way to store a NSString in a NSData maintaining the SAME data?
Example (this is fine, but it's not what I need):
NSString *tmpString = @"Hello World!";
NSData *nsdataString = [tmpString dataUsingEncoding:NSUTF8StringEncoding];
I need something like this (that obviously fail):
NSData nsdataString = @"Hello World!";
In few words: I need to use NSData like if it was the SAME of a NSString (like using a cast operator). This approach is very useful to preload an encrypted core data sqlite database (in a NSString) and decrypt only when the user access to the fields of persistent store.
To decrypt I use:
NSData *decryptedData = [encryptedData AES256DecryptWithKey:keyString];
Where encryptedData is a NSData and keyString is a NSString.
Thanks a lot to everybody!