开发者

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开发者_Python百科.

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;
}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜