0

How to download file without storing information on iCloud?

My App is the App for downloading pdf to the machine. It was rejected by Apple from the reason that "In particular, we found that after downloading two issues, your app stores 56.5 MB. To check how much data your app is storing: - Go to Settings> iCloud. > Storage & Backup> Manage Storage ". I would like to know how to write if the information is not stored on iClound.

My Script :

- (void) DownloadFile:(NSURL *)url Name:(NSString *)name Folder:(NSString *)folder{

    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSData *myData = [NSData dataWithContentsOfURL:url];
    NSString *file = [NSString stringWithFormat:@"%@/%@",folder,name];

    if(![fileManger fileExistsAtPath:file]){
        [fileManger createFileAtPath:file contents:myData attributes:nil];
    }
}
RohitWagh
  • 1,999
  • 3
  • 22
  • 43

2 Answers2

0

Just store the PDFs in the application document directory. You can still keep track of which files have been downloaded on which devices by using the iCloud's key-value store. However, the files to be downloaded onto the device would have to come from non-iCloud servers.

You will probably also have to implement a UI for showing which files have been downloaded and which are available and for deleting them from the device if desired.

Mundi
  • 79,884
  • 17
  • 117
  • 140
  • do I should delete object in NSManager ? for (NSManagedObject *object in moc.registeredObjects) { [moc deleteObject:object]; } ref : http://stackoverflow.com/questions/8021753/crash-when-adding-persistent-store-icloud-enabled-in-app-delegate – Titra Art Jun 08 '12 at 10:47
0

OH Thank you it complete

#import <sys/xattr.h>
....

-(BOOL) addSkipBackupAttributeToItemAtURL:(NSURL *)URL{
     if(&NSURLIsExcludeFromBackupKey == nil){
         const char* filePath = [[URL 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{
         return [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil];
     }
} 

- (void) DownloadFile:(NSURL *)url Name:(NSString *)name Folder:(NSString *)folder{

    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSURL *curfile = [NSURL fileURLWithPath:folder];
    [self addSkipBackupAttributeToItemAtURL:curfile];
    NSData *myData = [NSData dataWithContentsOfURL:url];
    NSString *file = [NSString stringWithFormat:@"%@/%@",folder,name];

    if(![fileManger fileExistsAtPath:file]){
        [fileManger createFileAtPath:file contents:myData attributes:nil];
    }
}

Thank you