Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4116698
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:44:27+00:00 2026-05-20T22:44:27+00:00

I’m parsing data from a file if the internet connection is unavailable. When I

  • 0

I’m parsing data from a file if the internet connection is unavailable. When I test this in the iphone simulator it works perfectly. when I switch to the device it fails. When I save and load the data I used the same name with no difference in case. What could be the problem?

- (void)parseXMLFileAtURL:(NSString *)URL
{
    events = [[NSMutableArray alloc] init];

    NSURL *xmlURL = [NSURL URLWithString:URL];

    NSString* xml = [[NSString alloc]initWithContentsOfURL:xmlURL];
    NSData * xmlData = [xml dataUsingEncoding:NSUTF8StringEncoding]; //[[NSData alloc]initWithContentsOfURL:xmlURL];
    if (xmlData != nil) {
        fileParser = [[NSXMLParser alloc] initWithData:xmlData];
        HBSaveData(xmlData, @"/xml.plist");
        NSLog(@"backup made %@ " ,xmlData);
    } else {
        xmlData = [[[NSData alloc]initWithData:HBLoadData(@"/xml.plist")]retain];

        fileParser = [[NSXMLParser alloc]initWithData:xmlData];
        networkConnected = YES;
        NSLog(@"backup used %@ " ,xmlData);
    }

    [fileParser setDelegate:self];

    [fileParser setShouldProcessNamespaces:NO];
    [fileParser setShouldReportNamespacePrefixes:NO];
    [fileParser setShouldResolveExternalEntities:NO];

    [fileParser parse];

}

This is the second issue i’ve had like this and I don’t understand why. I’ve used this same method of saving files 3 other times and now this time it doesn’t want to work. My other question remains unanswered.

Here are the save and load functions

static void HBSaveData(NSData *data, NSString* savePath){
    NSString *filePath = pathOfFile(savePath);
    NSString *errString;
    NSData *serialized =
    [NSPropertyListSerialization dataFromPropertyList:data
                                           format:NSPropertyListBinaryFormat_v1_0
                                 errorDescription:&errString];

[serialized writeToFile:savePath atomically:YES];

if (errString)
{
    NSLog(@"%@" ,errString);
    [errString release]; // exception to the rules
}


//[data writeToFile:filePath atomically:YES];
NSLog(@"%@", filePath);

}

static NSData* HBLoadData(NSString* savePath) {
    NSString *filePath = pathOfFile(savePath);

    NSString *errString;
    NSData *serialized = [NSData dataWithContentsOfFile:savePath];



NSData* data =
[NSPropertyListSerialization propertyListFromData:serialized
                                 mutabilityOption:NSPropertyListMutableContainers
                                           format:NULL
                                 errorDescription:&errString];

if (errString)
{
    NSLog(@"%@" ,errString);
    [errString release]; // exception to the rules
}
return data;

}

static inline NSString* pathOfFile(NSString * savePath){

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsFolder = [paths objectAtIndex:0];
return [documentsFolder stringByAppendingPathComponent:savePath];

}

I performed a test and looked at the contents of the file directory at read and write. on the simulator I have this.

2011-03-31 08:05:39.117 AnimeSTL[5992:207] All documents (
“myEventId.plist”,
“myEvents.plist”,
“myListEvents.plist”,
“xml.dat”
)

On the device I get this

2011-03-31 08:11:10.019 AnimeSTL[134:307] All documents (
“myEventId.plist”,
“myEvents.plist”,
“myListEvents.plist”
)
the file isn’t being saved for some reason.

edit:
The write fails so I output the file path anyway. is it because iphones can’t handle files of type .dat?

2011-03-31 09:48:50.954 AnimeSTL[196:307] All documents (
“myEventId.plist”,
“myEvents.plist”,
“myListEvents.plist”
)
2011-03-31 09:48:50.960 AnimeSTL[196:307] write failed
2011-03-31 09:48:50.962 AnimeSTL[196:307] /var/mobile/Applications/FCB4AA53-5450-495B-A190-930535335301/Documents/xml.dat

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:44:28+00:00Added an answer on May 20, 2026 at 10:44 pm

    Remember that the iOS file system is case sensitive, whereas the Mac OS X file system usually isn’t. So if your file is really called “XML.plist” instead of “xml.plist”, that’ll work on the simulator but not on the device.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an XML file, the creators of it stuck in a bunch social
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.