文档目录iOS中的文件读取错误

时间:2014-10-06 07:02:34

标签: ios filereader

从文档目录中读取文件时出现此错误。文件中的内容是加密字符串。我正在读取NSData中的文件内容。进一步我正在解密。但由于它无法读取任何内容,因此无法显示解密的内容。

我的代码是:

    //reading the file content
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"encryp.txt"];

if([[NSFileManager defaultManager] fileExistsAtPath:filePath])
{
   data1 = [[NSFileManager defaultManager] contentsAtPath:filePath];
}
    else
{
    NSLog(@"File not exits");
}

//解密文件内容

    NSError *error1;

NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];

strKey =[defaults valueForKey:@"hashOfPassword"];

NSData *decryptedData1 = [RNDecryptor decryptData:data1 withSettings:kRNCryptorAES256Settings password:strKey error:&error1];

NSLog(@"Decrypted Data is: %@", decryptedData1);

NSString* decryptedStr1 = [[NSString alloc] initWithData:decryptedData1 encoding:NSUTF8StringEncoding];

NSLog(@"dercrypted string is:%@", decryptedStr1);

通过添加断点,我收到了此错误

    (NSError *) error1 = 0x00000001 domain: <read memory from 0xd failed (0 of 4 bytes read)> - code: <read memory from 0x9 failed (0 of 4 bytes read)>

我没有得到这个。请帮助!!

0 个答案:

没有答案