Hi there,
i have the following problem i can't solve.
i have a NSMutableArray that contains about 12 NSDictionaries and i wanna save it to a plist file.
this is the code that save it
Code:
-(void)writeToPlist:(NSString*)plistFileName array:(NSMutableArray*)arrayToWrite
{
NSString *FileNamePath = [[NSString alloc] initWithFormat:@"%@.plist",plistFileName];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appSettingsPath = [documentsDirectory stringByAppendingPathComponent:FileNamePath];
[arrayToWrite writeToFile:appSettingsPath atomically:YES];
[FileNamePath release];
}
and this is the code that read the file after saving it
Code:
NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory2 = [paths1 objectAtIndex:0];
NSString *appSettingsPath2 = [documentsDirectory2 stringByAppendingPathComponent:@"ImageFileData.plist"];
imageArray = [[NSMutableArray alloc] initWithContentsOfFile:appSettingsPath2];
but it doesn't work, every time i start the app i got the count of imageArray = 0 . and i checked that there is an information that wrote to the plist file.
i print the result of this statement
Code:
[arrayToWrite writeToFile:appSettingsPath atomically:YES];
NSLog(@"%@",arrayToWrite);
i got this
Code:
(
{
"\U0627\U0644\U0639\U064a\U0646" = "/var/mobile/Applications/5756C245-756E-496C-A731-B23ADD2AA96C/Documents/1.gif";
},
{
"\U0627\U062a\U062d\U0627\U062f \U0643\U0644\U0628\U0627\U0621" = "/var/mobile/Applications/5756C245-756E-496C-A731-B23ADD2AA96C/Documents/2.png";
},
{
"\U0627\U0644\U0634\U0628\U0627\U0628" = "/var/mobile/Applications/5756C245-756E-496C-A731-B23ADD2AA96C/Documents/3.gif";
},
{
"\U0627\U0644\U0638\U0641\U0631\U0629" = "/var/mobile/Applications/5756C245-756E-496C-A731-B23ADD2AA96C/Documents/4.png";
},
{
"\U0627\U0644\U0648\U0635\U0644" = "/var/mobile/Applications/5756C245-756E-496C-A731-B23ADD2AA96C/Documents/5.jpg";
},
{
"\U0627\U0644\U062c\U0632\U064a\U0631\U0629" = "/var/mobile/Applications/5756C245-756E-496C-A731-B23ADD2AA96C/Documents/6.gif";
},
{
"\U0628\U0646\U064a \U064a\U0627\U0633" = "/var/mobile/Applications/5756C245-756E-496C-A731-B23ADD2AA96C/Documents/7.png";
},
{
"\U0627\U0644\U0648\U062d\U062f\U0629" = "/var/mobile/Applications/5756C245-756E-496C-A731-B23ADD2AA96C/Documents/8.gif";
},
{
"\U200e\U0627\U0644\U0634\U0627\U0631\U0642\U0629" = "/var/mobile/Applications/5756C245-756E-496C-A731-B23ADD2AA96C/Documents/9.png";
},
{
"\U0627\U0644\U0646\U0635\U0631" = "/var/mobile/Applications/5756C245-756E-496C-A731-B23ADD2AA96C/Documents/10.gif";
},
{
"\U062f\U0628\U064a" = "/var/mobile/Applications/5756C245-756E-496C-A731-B23ADD2AA96C/Documents/11.jpg";
},
{
"\U0627\U0644\U0623\U0647\U0644\U064a" = "/var/mobile/Applications/5756C245-756E-496C-A731-B23ADD2AA96C/Documents/12.gif";
}
)
so what is the solution if u know it. thx in advance.