Writing to file fails
I'm trying to write an NSMutableArray to a file, however it fails every single time. I believe that the path I have stated is correct. What else could be the problem?


    for (int i=1; i<=10/*[self getcurrentnumber]*/;i++)
    {
        [mutablearray addObject:[self convertJSONtoDictionary:[self generateJSONforcomic:[NSNumber numberWithInt:i]]]];
        NSLog(@"Iteration %i",i);
    }
    NSLog(@"Done %.0u",[mutablearray count]);
    
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
    NSString *libraryDirectory = [paths objectAtIndex:0];
    NSString *location = [libraryDirectory stringByAppendingString:@"/Comics.txt"];
    NSLog(location);
    [mutablearray writeToFile:location atomically:YES];
    if(![mutablearray writeToFile:location atomically:YES])NSLog(@"Fail");

I'm using introspection to ensure that convertJSONtoDictionary actually returns a dictionary.
Writing to file fails
===

I'm trying to write an NSMutableArray to a file, however it fails every single time. I believe that the path I have stated is correct. What else could be the problem?


    for (int i=1; i<=10/*[self getcurrentnumber]*/;i++)
    {
        [mutablearray addObject:[self convertJSONtoDictionary:[self generateJSONforcomic:[NSNumber numberWithInt:i]]]];
        NSLog(@"Iteration %i",i);
    }
    NSLog(@"Done %.0u",[mutablearray count]);
    
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
    NSString *libraryDirectory = [paths objectAtIndex:0];
    NSString *location = [libraryDirectory stringByAppendingString:@"/Comics.txt"];
    NSLog(location);
    [mutablearray writeToFile:location atomically:YES];
    if(![mutablearray writeToFile:location atomically:YES])NSLog(@"Fail");

I'm using introspection to ensure that convertJSONtoDictionary actually returns a dictionary.