objective c - Plists Loading On Simulator but Not On iPhone -


i have arrays filled strings being saved plists, runs fine on simulator when load app iphone arrays saved plists returned null. here code:

nsfilemanager *filemanager = [nsfilemanager defaultmanager];   // path balance.plist in documents directory nsarray *paths = nssearchpathfordirectoriesindomains(                                                      nsdocumentdirectory,                                                      nsuserdomainmask, yes                                                      ); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *path = [documentsdirectory stringbyappendingpathcomponent:@"balance.plist"]; nsstring *path2 = [documentsdirectory stringbyappendingpathcomponent:@"interest.plist"]; nsstring *path3 = [documentsdirectory stringbyappendingpathcomponent:@"principal.plist"]; nsstring *path4 = [documentsdirectory stringbyappendingpathcomponent:@"dates.plist"]; nsstring *path5 = [documentsdirectory stringbyappendingpathcomponent:@"paymentperiods.plist"]; nsmutablearray *testarray; nsmutablearray *interestarray; nsmutablearray *principalarray; nsmutablearray *datearray; nsmutablearray *paymentperiods; // check see if plist exists, if not create if ([filemanager fileexistsatpath: path]) {     // if file exists, read array file     testarray = [[nsmutablearray alloc] initwitharray:balancelabels];     interestarray =[[nsmutablearray alloc] initwitharray:interestlabels];     principalarray = [[nsmutablearray alloc] initwitharray:pricipallabels];     datearray = [[nsmutablearray alloc] initwitharray:datevalues];     paymentperiods = [[nsmutablearray alloc] initwitharray:paymentamounts];  } else { // if file doesn’t exist, create empty array balancelabels = [[nsmutablearray alloc] init];  }   [testarray writetofile:path atomically:yes]; [interestarray writetofile:path2 atomically:yes]; [principalarray writetofile:path3 atomically:yes]; [datearray writetofile:path4 atomically:yes]; [paymentperiods writetofile:path5 atomically:yes]; 

}

any suggestions?

so figured out have change nsstring nsurl

nsurl *documentsdirectory = [nsfilemanager.defaultmanager urlsfordirectory:nsdocumentdirectory                                                            indomains:nsuserdomainmask].firstobject; nsurl *path = [documentsdirectory urlbyappendingpathcomponent:@"balance.plist"]; nsurl *path2 = [documentsdirectory urlbyappendingpathcomponent:@"interest.plist"]; nsurl *path3 = [documentsdirectory urlbyappendingpathcomponent:@"principal.plist"]; nsurl *path4 = [documentsdirectory urlbyappendingpathcomponent:@"dates.plist"]; nsurl *path5 = [documentsdirectory urlbyappendingpathcomponent:@"paymentperiods.plist"]; nsmutablearray *testarray; nsmutablearray *interestarray; nsmutablearray *principalarray; nsmutablearray *datearray; nsmutablearray *paymentperiods; // check see if plist exists, if not create if ([filemanager fileexistsatpath:[documentsdirectory path]]) {     // if file exists, read array file     testarray = [[nsmutablearray alloc] initwitharray:balancelabels];     interestarray =[[nsmutablearray alloc] initwitharray:interestlabels];     principalarray = [[nsmutablearray alloc] initwitharray:pricipallabels];     datearray = [[nsmutablearray alloc] initwitharray:datevalues];     paymentperiods = [[nsmutablearray alloc] initwitharray:paymentamounts];  } else { // if file doesn’t exist, create empty array balancelabels = [[nsmutablearray alloc] init];  } [testarray writetourl:path atomically:yes]; [interestarray writetourl:path2 atomically:yes]; [principalarray writetourl:path3 atomically:yes]; [datearray writetourl:path4 atomically:yes]; [paymentperiods writetourl:path5 atomically:yes]; 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -