<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NSCachesDirectory &#8211; SMsoft &#8211; informatica e dintorni</title>
	<atom:link href="https://blog.smsoft.it/tag/nscachesdirectory/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.smsoft.it</link>
	<description>consigli settimanali su MacOS, GNU/Linux ed Open Source</description>
	<lastBuildDate>Tue, 02 Jul 2013 09:30:25 +0000</lastBuildDate>
	<language>it-IT</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=67436</generator>
	<item>
		<title>Apps must follow the iOS Data Storage Guidelines or they will be rejected</title>
		<link>https://blog.smsoft.it/2013/07/02/apps-must-follow-the-ios-data-storage-guidelines-or-they-will-be-rejected/</link>
					<comments>https://blog.smsoft.it/2013/07/02/apps-must-follow-the-ios-data-storage-guidelines-or-they-will-be-rejected/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 02 Jul 2013 09:30:25 +0000</pubDate>
				<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[IOS]]></category>
		<category><![CDATA[NSCachesDirectory]]></category>
		<category><![CDATA[NSDocumentDirectory]]></category>
		<guid isPermaLink="false">http://blog.smsoft.it/?p=2491</guid>

					<description><![CDATA[Dopo aver inviato l&#8217;ultima App IOS per la revisione, Apple ha rifiutato la richiesta e mi ha risposto con: [crayon-6a79c143c45cb482714178/] La segnalazione è chiara, così come è chiaro l&#8217;errore che ho commesso. Sbadatamente ho copiato il DB sqlite dell&#8217;app nella cartella Documenti (NSDocumentDirector), senza indicare che il DB non doveva essere salvato su iCloud. Bisogna ... <a title="Apps must follow the iOS Data Storage Guidelines or they will be rejected" class="read-more" href="https://blog.smsoft.it/2013/07/02/apps-must-follow-the-ios-data-storage-guidelines-or-they-will-be-rejected/" aria-label="Per saperne di più su Apps must follow the iOS Data Storage Guidelines or they will be rejected">Leggi tutto</a>]]></description>
										<content:encoded><![CDATA[<p>Dopo aver inviato l&#8217;ultima App IOS per la revisione, Apple ha rifiutato la richiesta e mi ha risposto con:</p><pre class="urvanov-syntax-highlighter-plain-tag">2.23

We found that your app does not follow the iOS Data Storage Guidelines, which is required per the App Store Review Guidelines.

In particular, we found that on launch and/or content download, your app stores 5.48 MB. To check how much data your app is storing:

- Install and launch your app
- Go to Settings > iCloud > Storage & Backup > Manage Storage
- If necessary, tap "Show all apps"
- Check your app's storage
.......</pre><p></p>
<p>La segnalazione è chiara, così come è chiaro l&#8217;errore che ho commesso.<br />
Sbadatamente ho copiato il DB sqlite dell&#8217;app nella cartella Documenti (NSDocumentDirector), senza indicare che il DB non doveva essere salvato su iCloud. Bisogna infatti ricordare che su iCloud vanno salvati solo i dati utente e non il database interno dell&#8217;app.</p>
<p>Le soluzioni sono due:<br />
<strong>1</strong> &#8211; nel caso di dati temporanei da cancellare a fine applicazione, si può salvare nella cartella dei temporani (NSCachesDirectory)<br />
<strong>2</strong> &#8211; salvare il file nella cartella dei documenti, ma escluderlo dal salvataggio su iCloud impostando l&#8217;attributo NSURLIsExcludedFromBackupKey oppure l&#8217;attributo kCFURLIsExcludedFromBackupKey. Potete utilizzare il seguente metodo:</p><pre class="urvanov-syntax-highlighter-plain-tag">#include < sys/xattr.h >
+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
    if (&NSURLIsExcludedFromBackupKey == nil) { // iOS <= 5.0.1
        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 { // iOS >= 5.1
        NSError *error = nil;
        [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];
        return error == nil;
    }
}</pre><p>e poi richiamarlo come segue:</p><pre class="urvanov-syntax-highlighter-plain-tag">+(void) checkAndCreateDatabase{
    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDir = [documentPaths objectAtIndex:0];
    NSString *dbPath = [documentsDir stringByAppendingPathComponent:dbName];

    NSURL *skipURL =[NSURL fileURLWithPath:dbPath];
    [self addSkipBackupAttributeToItemAtURL:skipURL];
}</pre><p></p>
<p>enjoy!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.smsoft.it/2013/07/02/apps-must-follow-the-ios-data-storage-guidelines-or-they-will-be-rejected/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
