ios - plist array null although the plist does contain a string -


i have plist file copied docs dir main bundle. if file exists in docs doesn't copy on how should work.

the problem have when initialise plist array either in appdelegate applicationdidfinishlaunching or rootviewcontrollers viewdidload or viewdidappear methods.

now plist in mainbundle gets copied on docs dir has 1 item string

the plist source contain string called gbp enclosed in array node correct.

i initialise plist nsmutablearray this

nsstring *rootpath2 = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0]; nsstring *plistpath2 = [rootpath2 stringbyappendingpathcomponent:@"currency.plist"]; thecurrency = [[nsmutablearray alloc] initwithcontentsoffile:plistpath2]; 

and in viewdidload or viewwillappear check array with:

nslog(@"array contains %@", thecurrency); 

how result null?

assuming found file, plist ought dictionary. array in plist ought have name identify it, try like:

nsdictionary *dict = [[nsdictionary alloc]initwithcontentsoffile:plistpath2]; nsarray *currencyarray = [dict objectforkey:@"currencyarraykey"]; 

where "currencyarraykey" key array in plist.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -