Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8108947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:16:02+00:00 2026-06-06T01:16:02+00:00

I am getting the following error when trying to save a file to disk:

  • 0

I am getting the following error when trying to save a file to disk:

ERROR IS Error Domain=NSCocoaErrorDomain Code=512 "The operation couldn’t be completed. (Cocoa error 512.)" UserInfo=0x8d44150 {NSFilePath=/Users/test/Library/Application Support/iPhone Simulator/5.1/Applications/C283C4FF-645A-4C97-BB87-9591ECC57B0D/Library/Caches/newsfeedCache, NSUnderlyingError=0x8d25870 "The operation couldn’t be completed. Is a directory"}

NSMutableData *data = [[NSMutableData alloc] init];
        NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];  

        NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:@"test", @"hula", nil];

        [archiver encodeObject:dict forKey:kDataKey];
        [archiver finishEncoding];

        NSLog(@"CACHE PATH IS %@", self.newsfeedCachePath_);

        NSError *error = nil;
        BOOL success = [data writeToFile:self.newsfeedCachePath_ options:NSDataWritingAtomic error:&error];
        if (success && !error){

        } else {
            FNLog(@"ERROR IS %@", [error description]);
        }

        [archiver release];
        [data release];

Here’s how I am creating the path:

- (NSString *)createDataPath {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *dataPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:cacheName];

    /* check for existence of cache directory */
    if ([[NSFileManager defaultManager] fileExistsAtPath:dataPath]) {
        return dataPath;
    }

    NSError *error = nil;
    /* create a new cache directory */
    if (![[NSFileManager defaultManager] createDirectoryAtPath:dataPath
                                   withIntermediateDirectories:NO
                                                    attributes:nil
                                                         error:&error]) {
        DLog(@"Unresolved error %@, %@", error, [error userInfo]);
        return nil;
    }    

    NSString *path = [dataPath stringByAppendingPathComponent:cachePath];

    return path;
}

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:16:03+00:00Added an answer on June 6, 2026 at 1:16 am

    Take Finder, navigate to Home/Library/Application Support/iPhone Simulator/5.1/Applications/C283C4FF-645A-4C97-BB87-9591ECC57B0D/Library/Caches. Is newsfeedCache really a directory?

    EDIT: [data writeToFile:] expects a file name, not a directory name. if you feed a directory name to it, that’s an error. You have to come up with some kind of scheme for data storage. Without knowing the particulars of your application, I cannot come up with that for you. Are you going to have one file under that cache or many? How are you going to retrieve them later on? And so forth. Those are rhetorical questions. Answer them for yourself, and based on those answers, come up with a file naming scheme.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting the following error when trying to check in my code: $>
I'm getting the following error when trying to write a string to a file
Im getting invalid argument error when running the following code. Im trying to change
Getting the following error when trying to start a session: Warning: session_start() [function.session-start]: Node
I'm getting the following error when trying to delete objects in my database while
I'm getting the following error when trying to setup SQL Server 2005 DB Mirroring
I'm getting the following error when trying to convert HL7v3 to HL7v2 The message
I am getting the following error when trying to run reports. any thoughts or
I am getting the following error when trying to update my project from Intellij
I am getting the following error when trying to update an object using nhibernate.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.