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

  • SEARCH
  • Home
  • 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 6093685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:35:21+00:00 2026-05-23T12:35:21+00:00

I’m working on an app that writes data out to a .plist from a

  • 0

I’m working on an app that writes data out to a .plist from a view and then pulls it in to populate some UILabels in another view. I’ve done this several times in the past and it has worked fine on both the device and simulator. This time it’s working fine on the simulator but not on the device. I’ve been through looking at all the connections and code but just can’t find why it’s not functioning. My suspicion is that for some reason the data is not at the end of the file path, but if it isn’t I can’t understand why this is the case.

I’ve Also tried cleaning the targets through the menu and deleting and reinstalling the app on the testing device in the hope that this may rectify the situation, but no joy.

Can anyone offer some insight into why I’m having this problem and how to rectify it? It’s why it works on the simulator but not the phone that is confusing me, especially when I’ve used the same code in the past to make fully functioning apps. I’m using xCode 4 and testing on an iphone 4:

The code is as follows. First I check to see if there is data at the end of a data file path like this:

- (NSString *)dataFilePath
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirctory = [paths objectAtIndex:0];
    return [documentsDirctory stringByAppendingPathComponent:memberDetails];
}

Then in viewWillAppear I get the data and use it to populate UIlabels in the View. a Few of the labels are visible or invisible based on the data they contain. The viewWillAppear is as follows:

-(void)viewWillAppear:(BOOL)animated

{

// Check data file path and if it exists, load data from there. 
    NSString *filePath = [self dataFilePath];
    if ([[NSFileManager defaultManager] fileExistsAtPath:filePath])

    {
        ///All of the following handles the reloading of data from the plist.
        NSArray *array = [[NSArray alloc] initWithContentsOfFile:filePath];
        memName.text = [array objectAtIndex:0];
        memAddress.text = [array objectAtIndex:1];
        memOccupation.text = [array objectAtIndex:2];
        sherex.text = [array objectAtIndex:3];


        if ([[array objectAtIndex:3] isEqualToString:@"winstonwinston"]) {
            cvName.hidden = NO;
            memName.hidden = NO;
            cvAddress.hidden = NO;
            memAddress.hidden = NO;
            cvOccupation.hidden = NO;
            memOccupation.hidden = NO;
            sherex.hidden = YES;
            altText.hidden = YES;


        } 
        else {
            cvName.hidden = YES;
            memName.hidden = YES;
            cvAddress.hidden = YES;
            memAddress.hidden = YES;
            cvOccupation.hidden = YES;
            memOccupation.hidden = YES;
            sherex.hidden = YES;
            altText.hidden = NO;
        }



        [array release];

    }
    [super viewWillAppear:animated];  
    }

One thing perhaps worth pointing out is that the if/else statement doesn’t seem to be working on the device either. In other words everything in the view is visible. To me this would seem to suggest that the problem might not be the data since if should be able to determine whether or not there is an item called ‘winstonwintson’ in existence or not and display the hidden/showing elements of the view accordingly.

If anyone has some insight please help! I’m totally stuck. Thanks for taking the time to read this.

  • 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-23T12:35:21+00:00Added an answer on May 23, 2026 at 12:35 pm

    If it involves files and works on the simulator but not on the device it’s usually one of two problems.

    1. you use filenames that work ok on a case insensitive file system (the simulator) but not on the device (case sensitive filesystem).
      The only way I can imagine how this affects you is when you try to copy an initial dataset to the documents directory. For example if you try to copy from your bundle, check the path that is returned by [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"bar"]; If the path is nil you have to check your filenames again, they have to be exactly the same.

    2. you write to directories that are not writeable on the device.
      One very unlikely possibility is that memberDetails contains something like /../foo and you try to write in a non writeable directory. On the simulator you can write your files wherever you want, on the device such accesses will fail.

    So the two questions you should try to answer are:

    • how do you save the data in the documents directory?
    • what is the content of memberDetails? (how does the returned path from dataFilePath look?)

    EDIT:

    NSLog is always a great help in debugging such problems, just print out your paths and check if they are ok.

    Something like this:

    NSString *sourcePath = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"bar"];
    NSLog(@"Source: %@", sourcePath);
    if (![[NSFileManager...
    

    or you could use a if condition

    if (sourcePath == nil) {
        NSLog(@"Something is wrong with the sourcePath, because sourcePath == nil!");
    }
    

    EDIT2:

    Since neither of those view configuring parts are called most likely if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) is never true. This means the file does not exist.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.