ios - loading the arrays that are stored in the plist -
i have plist holds in each dictionary info node. every node has longitude, latitude , connections other nodes. here small piece of plist.
<array> <dict> <key>connections</key> <array> <integer>1</integer> <integer>3792</integer> </array> <key>latitude</key> <real>45.43876</real> <key>longitude</key> <real>12.3213</real> </dict> <dict> <key>connections</key> <array> <integer>0</integer> <integer>3793</integer> </array> <key>latitude</key> <real>45.43887</real> <key>longitude</key> <real>12.32122</real> </dict>
also have class called ignode store info, see here .m implementation. assume header isn't needed show here.
#import <foundation/foundation.h> @interface ignode : nsobject @property double lon; @property double lat; @property(nonatomic,strong) nsmutablearray *links; @end
so far have loading of latitude , longitude work. have no clue on how connections array out of plist. looked @ lot of examples on stackoverflow can't translate them have do.
this have far.
for (int i=0; i<plistdata.count; i++) { nsdictionary *nodedict = plistdata[i]; ignode *node = [self.nodes objectatindex:i]; node.lon = [[nodedict valueforkey:@"longitude"] doublevalue]; node.lat = [[nodedict valueforkey:@"latitude"] doublevalue]; // handle connections // ? }
how can store connections array in node.links?
have tried this....
nsstring *plistpath = [[nsbundle mainbundle] pathforresource:@"configs" oftype:@"plist"]; nsarray *tmpdicts = [[nsarray alloc] initwithcontentsoffile:plistpath];
you can enumerate array of tmpdicts , extract connections array each one.
ignode *node; (nsdictionary *dict in tmpdicts) { node = [[ignode alloc]init]; node.lon = [[dict valueforkey:@"longitude"] doublevalue]; node.lat = [[dict valueforkey:@"latitude"] doublevalue]; node.links = [[dict valueforkey:@"connections"]mutablecopy]; // node (like add array?) }
Comments
Post a Comment