iphone - Cannot determine between plist and sqlite3 -
i have been debating between .plist , sqlite3 database hold data need access, not manipulate within .plist/database. here question. lets want store height , color of trees, flowers, bushes , want each piece of information accessible. below similar like:trees palm 6 feet green willow 8 feet brown bushes evergreen 5 feet green cinquefoil 2 feet yellow flowers rose 1 foot red tulips 2 feet yellow
so if want individually access 2 feet height under tulips , display in text box in app..what best form of data store/resource use.  .plist or sqlite?  how lay out .plist?
 always, appreciate time , efforts!! thanks!
since dont have data use  .plist easier manage 
make each parent trees,flowers,bushes , array make each child item dictinary , when check if child satisfies requirement 2 feet height under tulips  use it.
create plist this:

code sample: note:i didnt test need improve
you can use kind of logic here check color,kind or height.
i giving example project see how filter plist, change name of function wish.
i won't  change function names cause "nobody aint got time that" :) create nsobject class called parsescheduleplist
in parsescheduleplist .h
#import <foundation/foundation.h> @interface parsescheduleplist : nsobject @property (nonatomic,strong) nsmutabledictionary * agendadic; - (void)passstringtoagendadic:(nsstring *)string; //trees -(nsarray*)gettrees; -(nsdictionary*)getitems:(nsinteger ) section ; -(nsstring*)getitemkind :(nsinteger ) section; -(nsstring*)getitemcolor :(nsinteger ) section; -(nsnumber*)getitemheight :(nsinteger ) section; //flowers //do same of above flowers bushes took @end   in parsescheduleplist .m
#import "parsescheduleplist.h"  @implementation parsescheduleplist @synthesize agendadic = _agendadic; - (void)passstringtoagendadic:(nsstring *)string {     //get plist bundle         nsstring * path = [[nsbundle mainbundle] pathforresource:string oftype:@".plist"];         bool fileexists = [[nsfilemanager defaultmanager] fileexistsatpath:path];         nslog(fileexists ? @"yes" : @"no");         nslog(@"path %@",path);         nslog(@"agendadic  %u",[self.agendadic count]);         self.agendadic = [nsmutabledictionary dictionarywithcontentsoffile:path];    } -(nsarray*)gettrees {     nsarray * value = [[self agendadic]  objectforkey:@"trees"];     return value; } -(nsdictionary*)getitems:(nsinteger ) section {     nsdictionary * value =[[self gettrees] objectatindex:section];     return value; } -(nsstring*)getitemkind :(nsinteger ) section; {     nsstring * value =[[[self getitems] objectatindex:section] objectforkey:@"kind"];     return value; }  -(nsstring*)getitemcolor :(nsinteger ) section {     nsstring * value =[[[self getitems] objectatindex:section] objectforkey:@"color"];     return value; }  -(nsnumber *)getitemheight :(nsinteger ) section; {     nsnumber * value =[[[self getitems] objectatindex:section] objectforkey:@"height"];     return value; }  //write same functions flowers , bushes  @end   in regular view controller .h:
#import "parsescheduleplist .h" @property (nonatomic, strong) parsescheduleplist *agenda;   in regular view controller .m:
#import "parsescheduleplist .h" @synthesize agenda;  //here calls special class     self.agenda=[[parsescheduleplist alloc] init];     [self.agenda passstringtoagendadic:@"name of plist"];      nsmutablearray *newarray=[ nsmutablearray alloc] init];      //here example palm trees under 6 feet     for(int i=0; i<[self.agenda gettrees] count] i++)     {        if([self.agenda getitemkind :i] isquealtostring @"palm"){              if([self.agenda getitemheight :i] <= 6)                  [newarray add object:[self.agenda getitems:i];         }     }      nslog(@"print array %@",newarray);      
Comments
Post a Comment