App Rejected

Discussion in 'iOS Programming' started by larswik, Jun 2, 2013.

  1. larswik macrumors 68000

    Joined:
    Sep 8, 2006
    #1
    The app I created goes with my TV show that I have in local hotels. Visitors download the app and they get more info about shops and restaurants they see on the show.

    When the user downloads the app if fetches the latest images and text and loads it to the phone.

    Apple: "2.23: Apps must follow the iOS Data Storage Guidelines or they will be rejected"

    Once everything is downloaded the app runs smoothly because it is all cached on the phone. But from reading this, Temporary files used by your app should only be stored in the /tmp directory; please remember to delete the files stored in this location when the user exits the app. It appears that Apple wants me to delete this data when the app closes?

    This causes my app to needlessly download the same data over and over again when the app is launched every time. Not to mention the app will always be slow. Now when a user clicks on a button they have to wait for that data to load to view it.

    Are there any ways to store the data on the phone? My app I released 1 years a go for a different market went through just fine. But this was before the iCloud stuff.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Temporary usually means data generated by the program for temporary use.

    In your description:
    the underlined part refers to cached data, as distinct from temporary.

    The distinction is that your program can't generate (create or produce) the data by itself. It must fetch the data from some other source. If the network were exceptionally fast, it would need to do the same thing: fetch it rather than generate it by itself. An exceptionally fast network would mean you don't need to cache the data, but you still need to fetch it.

    So change your implementation to cache the fetched data in the appropriate location, and also manage the size and contents of that cache.

    Short answer: look up where to cache data fetched from elsewhere, and don't store it in /tmp.
     
  3. larswik thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #3
    Thanks, I read up on everything today and the directory structure in ios. I am now adding my images and other data to the /Library/Cache instead of /Documents.

    I added this method to flag each file to prevent my files from being backed up the the iCloud. But I don't think I need this method since none of my downloaded data resides in the /Documents directory anymore.

    Code:
    - (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
    {
        assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);
        
        NSError *error = nil;
        BOOL success = [URL setResourceValue:[NSNumber numberWithBool: YES]
                                      forKey: NSURLIsExcludedFromBackupKey error: &error];
        if(!success){
            NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
        }
        
        return success;
    }
    
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    You're right; it's unnecessary. The cache folder is excluded from backups. It's also excluded from transfer to iTunes, and may be cleared under certain circumstances. You should read up on it.
     
  5. larswik thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #5
    I'm blown away by how vast Objective C is with all of these classes. I have been at it for a couple of years now and I feel I have just scratched the surface. Not to mention it is always changing.

    Thanks for your help, again!
     
  6. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #6
    Two ways to keep up your knowledge of what is available is to read the developer release notes for each iOS version, and download all of the WWDC videos & watch what captures your interest. Oh, when I'm searching the docs, I sometimes see interesting things that I jump to instead of what I initially was looking for.
     
  7. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #7
    It's not Objective C, it's the iOS frameworks. Objective C is fairly small language.

    It is humbling how broad and deep the frameworks are, isn't it?

    ----------

    Yup, you want to use Caches instead of documents.

    That way the system can purge the caches when it needs the room, but in the meantime your user gets the benefit of not re-downloading everything.

    You might want to save timestamps for the files you cache. You can then either ignore files older than a certain date, or implement a scheme where you ask your server for a single table with all the modified dates at startup, and check against that when you find a cached image. That way you can force refreshes on any files that you need to.
     
  8. larswik thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #8
    It is humbling. Sometimes I will write a method to perform a task only to find out there is a Class for that.

    I think what has helped me, which was slowly learned over the years, is to get the basics down and understanding how things function. Google has been a blessing and a curse when learning. You can find what you are looking for most of the time but that leads to copy / paste code. When I copy paste I didn't learn it.

    I have watched some of the WWDC videos with my free time :)

    Thanks!
     
  9. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #9

    I tend to use Google to find APPROACHES when I'm stuck, and then implement my own solution.

    I will sometimes drop in 3rd party libraries, but don't tend to copy-and-paste code.
     

Share This Page