actionscript 3 - How to store constant data in Objective c? -
i'm as3 game developer trying head around obj-c. 1 of things i'm not sure obj-c how store game data. in as3 this...
static var playerdata:object = {position:{startx:200, starty:200}};
which can access this...
var x1:number = playerdata['position']['startx'];
or if had multiple rows of data this...
mydata["runonframe" + currentimageindex]
where access object runonframe1, runonframe2 , on.
i asked question yesterday how setup initial data structure above, , got answers back...
how create as3 data structure in objective c?
but way of setting basic game data using mutable dictionary seems bit long winded least.
so getting point of question (finally), taking how set things in as3 account, best way me set game data in obj-c? seem options are...
use mutable dictionary approach in above link
set class holds data basic vars, i'm not sure how access vars in class dynamically (like runonframe example)
- maybe use array, lose labeling think.
or there better ways? xml? i'm using parse project, seems great, , i'm wondering if should store data directly using parse, data accessed database right get-go, maybe thing start off with. having said know there's going data want hard code game, ideas on how best appreciated!
your observation of initializing mutable dictionary item-by-item being long correct. in fact, the upcoming version of objective c provide better syntax task:
nsdictionary *playerdata = @{ @"position" : @{@"startx":@200, @"starty":@200} };
however, there can until nice syntax becomes available: can prepare dictionary long way, save in file property list, , replace long initialization code single read of plist, way this answer previous question suggests:
playerdata = [nsmutabledictionary dictionarywithcontentsoffile:@"playerdata.plst"];
Comments
Post a Comment