xcode - Stumped: property list works in simulator and in other Apps, but not when I test on the iphone 4 -


i'm working on app writes data out .plist view , pulls in populate uilabels in view. i've done several times in past , has worked fine on both device , simulator. time it's working fine on simulator not on device. i've been through looking @ connections , code can't find why it's not functioning. suspicion reason data not @ end of file path, if isn't can't understand why case.

i've tried cleaning targets through menu , deleting , reinstalling app on testing device in hope may rectify situation, no joy.

can offer insight why i'm having problem , how rectify it? it's why works on simulator not phone confusing me, when i've used same code in past make functioning apps. i'm using xcode 4 , testing on iphone 4:

the code follows. first check see if there data @ end of data file path this:

- (nsstring *)datafilepath {     nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes);     nsstring *documentsdirctory = [paths objectatindex:0];     return [documentsdirctory stringbyappendingpathcomponent:memberdetails]; } 

then in viewwillappear data , use populate uilabels in view. few of labels visible or invisible based on data contain. viewwillappear follows:

-(void)viewwillappear:(bool)animated  {  // check data file path , if exists, load data there.      nsstring *filepath = [self datafilepath];     if ([[nsfilemanager defaultmanager] fileexistsatpath:filepath])      {         ///all of following handles reloading of data 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 if/else statement doesn't seem working on device either. in other words in view visible. me seem suggest problem might not data since if should able determine whether or not there item called 'winstonwintson' in existence or not , display hidden/showing elements of view accordingly.

if has insight please help! i'm totally stuck. taking time read this.

if involves files , works on simulator not on device it's 1 of 2 problems.

  1. you use filenames work ok on case insensitive file system (the simulator) not on device (case sensitive filesystem).
    way can imagine how affects when try copy initial dataset documents directory. example if try copy bundle, check path returned [[nsbundle mainbundle] pathforresource:@"foo" oftype:@"bar"]; if path nil have check filenames again, have exactly same.

  2. you write directories not writeable on device.
    1 unlikely possibility memberdetails contains /../foo , try write in non writeable directory. on simulator can write files wherever want, on device such accesses fail.

so 2 questions should try answer are:

  • how save data in documents directory?
  • what content of memberdetails? (how returned path datafilepath look?)

edit:

nslog great in debugging such problems, print out paths , check if ok.

something this:

nsstring *sourcepath = [[nsbundle mainbundle] pathforresource:@"foo" oftype:@"bar"]; nslog(@"source: %@", sourcepath); if (![[nsfilemanager... 

or use if condition

if (sourcepath == nil) {     nslog(@"something wrong sourcepath, because sourcepath == nil!"); } 

edit2:

since neither of view configuring parts called if ([[nsfilemanager defaultmanager] fileexistsatpath:filepath]) never true. means file not exist.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -