- (void)writeToDiskArray:(NSArray *)json
{
    //Creating a file path under iOS:
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

    NSString *filename = [documentsDirectory stringByAppendingPathComponent:@"artists.txt"];
    NSDictionary *artists = [json valueForKey:@"artists"];

    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:artists];
    [data writeToFile:filename atomically:YES];

    NSLog(@"\n\n\n\nWriting data to:%@\n\n\n\n", filename);

}
Advertisements