Carl
Carl

Reputation: 1276

Cocoa Development - Having trouble loading local XML files when running from device

I have a program that runs perfectly fine when I run on the simulator, but it won't run from the device at all. Part of the initial run involves loading a few XML files into core data and it seems that these files are not being found when running on the device.

Here is the beginning of the routine that loads the file. Any help is much appreciated.

- (BOOL) checkForUpdate:(NSString *)entityName {

    NSArray *thisObjectArray = nil;
    NSDate *thisEntityDate = nil;
    BOOL returnVal = NO;

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

    NSEntityDescription *entity = [NSEntityDescription entityForName:@"AppData" inManagedObjectContext:[self managedObjectContext]];
    [fetchRequest setEntity:entity];

    NSError *error;
    NSArray *appDataArray = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];

    [fetchRequest release];

    AppData *thisAppData = [appDataArray objectAtIndex:0];

    if ([entityName isEqualToString:@"Features"]) {
        thisEntityDate = thisAppData.FeaturesUpdated;
    }
    else if ([entityName isEqualToString:@"DisplayTypes"]) {
        thisEntityDate = thisAppData.DisplayTypesUpdated;
    }
    else if ([entityName isEqualToString:@"Sections"]) {
        thisEntityDate = thisAppData.SectionsUpdated;
    }


    NSString *filePath = [[NSBundle mainBundle] pathForResource:entityName ofType:@"xml"];
    NSData *xmlData = [[NSMutableData alloc] initWithContentsOfFile:filePath];
    GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:xmlData options:0 error:&error];

    if (doc != nil) { 
        // process information - this code is not being called because doc is returning nil
    }


[xmlData release];
[doc release];

   return returnVal;
}

Upvotes: 0

Views: 104

Answers (1)

albertamg
albertamg

Reputation: 28572

Mind the case sensitivity. The device is case sensitive, whilst the simulator is not.

Upvotes: 1

Related Questions