I am a newcomer to iOS development. I would like to do encryption and decryption. My question is the following: When I was running my code, the decryption was working fine in the simulator but it is not running on an iPhone device. I get the following error message shown below:
[__NSArrayM insertObject:atIndex:]: object cannot be nil
Here is my code. I have defined an array containing multiple strings:
<dictionary>
<array>
<string>india,chennai,salem,coimbatore,krishnagiri,hosur,palghat</string>
<string>india1,chennai1,salem1,coimbatore1,krishnagiri1,hosur1,palghat1</string>
</array>
</dictionary>
NSString *stringIndex1 = [[NSString alloc]init];
NSMutableArray *arrAthigaaramList1;
dictDecryptList=[[NSMutableDictionary alloc]init];
for(int i=0;i<[arrD_Chapter count];i++)//50 Chapter wise
{
stringIndex1 = [arrD_Chapter objectAtIndex:i];
NSData *b64DecData = [Base64 decode:stringIndex1];
NSData *decryptedData = [[NSData alloc]init];
decryptedData= [b64DecData AESDecryptWithPassphrase:@"mypassword"];
NSString *decryptedStr = [[NSString alloc] initWithData:decryptedData encoding:NSUTF32StringEncoding];
NSLog(@"Decryped Data Base 64 encoded = %@",decryptedStr);
[arrAthigaaramList1 addObject:decryptedStr];
}
What is wrong with this code?
NSString *decryptedStr = [[NSString alloc] initWithData:decryptedData encoding:NSUTF32StringEncoding];is resulting in anilstring. What's the output of your log?