0

I,

I'm currently trying to save NSMutable data in a plist file with the following method:

[receivedData writeToFile:pathText atomically:YES]

Note that received data comes from an URLrequest object. Here is my code:

NSURLConnection *connection01 = [[NSURLConnection alloc] initWithRequest:request01 delegate:self];
        if(connection01)
        {

        //3.Create NSMutableData to receive data
        //receiveddata is an instance declared elsewhere

        receivedData = [NSMutableData data];
        }

and after

//6.Mettre les informations téléchargées dans un plist.

        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSLog(@"DOCUMENT DIRECTORY:  %@", documentsDirectory);
        NSString *pathNom = [documentsDirectory stringByAppendingPathComponent:@"InformationsUser.plist"];
        NSString *pathText = @"/Users/victorbielak/Desktop/InformationUser.text";

        [receivedData writeToFile:pathText atomically:YES];

        if (!documentsDirectory) {
            NSLog(@"Documents directory not found!");
        }
        if(![[NSFileManager defaultManager] fileExistsAtPath:pathNom])
        {
            NSLog(@"file not found");

        }

the error message "file not found" appears, although I checked that the information under the URL was correctly downloaded. Does someone have an idea of what is missing in that code? I though that the plist was automatically generated by the write to file method.

Thank you for your response.

Victor

Vico la patate
  • 209
  • 2
  • 4
  • 12

1 Answers1

0

you should be using pathNom instead of pathText.. :)

Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115