iphone - How to parse different files depending on the current date in Xcode? -
i have following problem: building app tv guide. parsing listing channels xml file on internet. code:
-(void)loadlisting { nsurl *urllisting = [nsurl urlwithstring:@"http://pik.bg/tv/bnt1/29.03.2013.xml"]; nsdata *webdatalisting = [nsdata datawithcontentsofurl:urllisting]; nsstring *xpathquerylisting = @"//elem/title"; tfhpple *parserlisting = [tfhpple hpplewithxmldata:webdatalisting]; nsarray *arraylisting = [parserlisting searchwithxpathquery:xpathquerylisting]; nsmutablearray *newarraylisting = [[nsmutablearray alloc] initwithcapacity:0]; (tfhppleelement *element in arraylisting) { listing *shows = [[listing alloc] init]; [newarraylisting addobject:shows]; shows.broadcast = [[element firstchild] content]; } _shows = newarraylisting; [self.tableview reloaddata]; }
look @ first row - file's name /.../01.04.2013.xml tomorrow's file /.../02.04.2013.xml , etc. how make parse different files depending on current date? this: today parses /.../01.04.2013, tomorrow parse /.../02.04.2013 , etc. ? in advance!
first of all, today's date same format used in url. (you have play separate
date
,month
,year
components)then, convert date
nsstring
objectform
nsstring
nsstring *strtoday = [nsstring stringwithformat:@http://pik.bg/tv/bnt1/%@.xml",strtoday];
use string
nsurl
, like;nsurl *urllisting = [nsurl urlwithstring:strtoday];
note solution work if url contains date format specified you.
Comments
Post a Comment