RemoveFileAtPath alternative

Discussion in 'iOS Programming' started by boyplunder, Dec 9, 2009.

  1. macrumors regular

    boyplunder

    Joined:
    Sep 8, 2008
    Location:
    UK
    #1
    A few days after submitting our latest app for review, we had an email back saying that it wouldn't be approved because it uses a private API. The message states:

    Interestingly, this is used in an app we've had on the store since August, and we had an email on that too, as they have only just noticed it. So, does anyone have an alternative for this? It is used to remove the existing database so the latest read only database is used instead.

    Here is the part it appears in:
    Code:
    - (void)checkAndCreateDatabase {
    	// Check if the SQL database has already been saved to the users phone, if not then copy it over
    	BOOL success;
    	
    	// Create a FileManager object, we will use this to check the status
    	// of the database and to copy it over if required
    	NSFileManager *fileManager = [NSFileManager defaultManager];
    	
    	//Delete the current database so it is updated each time.
    	//Solves db updates without leaving copies.
    	[fileManager removeFileAtPath:databasePath handler:nil];
    	
    	// Check if the database has already been created in the users filesystem
    	success = [fileManager fileExistsAtPath:databasePath];
    	
    	// If the database already exists then return without doing anything
    	if (success) return;
    	
    	// If not then proceed to copy the database from the application to the users filesystem
    	
    	// Get the path to the database in the application package
    	NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName];
    	
    	// Copy the database from the package to the users filesystem
    	[fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
  3. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    Try using removeItemAtPath:error: instead. That's published.

    Yeah, seems they have a new tool to check for unpublished API calls. They have been cracking down on them lately.
     
  4. thread starter macrumors regular

    boyplunder

    Joined:
    Sep 8, 2008
    Location:
    UK
    #4
    Thanks Dejo, that works a treat.

    It's been a long learning curve and I don't recall how I arrived at the removeFileAtPath:handler wording, but I have read the section throughout, slapped my wrist and will move on for the better.
     

Share This Page