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

  • Home
  • SEARCH
  • 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 8356851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:18:17+00:00 2026-06-09T10:18:17+00:00

i am storing some downloaded files in NSDocumentDirectory and i need to mark those

  • 0

i am storing some downloaded files in NSDocumentDirectory and i need to mark those files as “do not backup”.

here is the code i have given

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL1
    {
       if (&NSURLIsExcludedFromBackupKey == nil) { // iOS <= 5.0.1
       const char* filePath = [[URL1 path] fileSystemRepresentation];

       const char* attrName = "com.apple.MobileBackup";
       u_int8_t attrValue = 1;

      int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
      return result == 0;
     } else { // iOS >= 5.1
                NSError *error = nil;
               [URL1 setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];

               return error == nil;
                NSLog(@"success");
            }
      }

littile bit confused about which url should given for ths method? downloading url or the downloaded file path url?
can i use like

  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);


  NSString *documentsDirectoryPath = [[paths objectAtIndex:0]stringByAppendingPathComponent:@"MdMus.mp3"];
  [receivedData writeToFile:documentsDirectoryPath atomically:YES];

need to use this one

     NSURL *url=[NSURL fileURLWithPath:documentsDirectoryPath];  
   [self addSkipBackupAttributeToItemAtURL:url];

or this

     [self addSkipBackupAttributeToItemAtURL:DownloadingURL];

need help

  • 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-09T10:18:18+00:00Added an answer on June 9, 2026 at 10:18 am

    if you want filesharing all user-data(in DocumentDirectory all data) prevent backup. refer a following code.

    - (void)addAttributeToAllFolder
    {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsPath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
        NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsPath error:nil];
    
        for (int i =0; i < [dirContents count]; i++) {
            NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@",documentsPath,[dirContents objectAtIndex:i]]];
            //this is your method (addSkipBackupAttributeToItemAtURL:)
            if ([self addSkipBackupAttributeToItemAtURL:url]) {
                NSLog(@"success! could add do not backup attribute to folder");
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am storing some mp3 files locally on a simulator using the following
I have an issue while storing some special character values into db. For e.g.
I have made a tree structure using c and used it for storing some
I have some code that needs to work with X509 Certificate information. I have
Need some guidance. I have java webstart app and I want it to connect
I receive some xml-files with embedded base64-encoded images, that I need to decode and
I have a page in JSP that list some file that could be downloaded
I have some requirements to protect some sensitive data. The data is downloaded as
I have to write a small app which downloads a few thousand files. Some
I'm working on some requirements that will lead to arbitrary PDF files being downloaded

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.