How to retrieve the pretext before an array in iOS Objective C (parse) -
array object @ index 0---:
<merchandise:aw9jgreryq:(null)> { acl = "<pfacl: 0x201b2590>\"; coverphotos = "<itemphotos:l5ln3zn5rm>\"; item = ugh; listingprice = 356; originalprice = "25)"; user = "<pfuser:kdrfesaja3>"; },
i have implemented ios app using parse.com
in have array of objects (array of dictionaries)
in have print 1st object of array..
i have pre text merchandise:aw9jgreryq:(null before every object / dictionary related object id
i want pretext " merchandise:aw9jgreryq:(null) " or atleast "aw9jgreryq"
how ..>?
total entire array of objects is
array-------
( "<merchandise:aw9jgreryq:(null)> {\n acl = \"<pfacl: 0x201b2590>\";\n coverphotos = \"<itemphotos:l5ln3zn5rm>\";\n photos = \"<pfrelation: 0x201bff80>(<00000000>.(null) -> itemphotos)\";\n brand = \"baby gap\";\n description = \"\\nfight\";\n item = ugh;\n listingprice = 356;\n originalprice = \"25)\";\n user = \"<pfuser:kdrfesaja3>\";\n}", "<merchandise:bmpfijerwi:(null)> {\n acl = \"<pfacl: 0x201a2300>\";\n coverphotos = \"<itemphotos:4pm7vx7q26>\";\n photos = \"<pfrelation: 0x2019a490>(<00000000>.(null) -> itemphotos)\";\n brand = \"3 pommes\";\n description = sett;\n item = udder;\n listingprice = 245;\n originalprice = 245;\n user = \"<pfuser:kdrfesaja3>\";\n}" )
it seems have 2 options this. either parse each 1 out string (definitely less elegant/way uglier way). or looks more array of arrays contain string , dictionary.
if ends being second option, grab object @ index 0 twice pretext looking for. however, if thats no avail..then can go so:
//convert object nsstring nsstring *converted = (nsstring*)[yourarray objectatindex:i]; //or..your may need nsstring *converted = [nsstring stringwithformat:@"%@",[yourarray objectatindex:0]]; nsarray *firstsplitterarray = [converted componentsseparatedbystring:@"<"];//split < nsstring *partialsplit = [splitterarray objectatindex:0]; nsarray *secondsplitterarray = [partialsplit componentsseparatedbystring:@">"];//split > nsstring *yourpretext = [secondsplitterarray objectatindex:0];//final step //now yourpretext should equal merchandise:aw9jgreryq:(null)
i wrote according first code snippet. if there leading quotation mark or something, you'll need change indexes. gives idea. print statements verify arrays @ each step , go. not cleanest, if in pinch work.
Comments
Post a Comment