iphone - @property scope issues and memory problems -
i having crash not understand. downloading couple files remote server, , when file has finished downloading, attempting retrieve object attached request object.
tia help!
s.
main class
for (trainingentry* _entry in objects) { httprequest * request = [httprequest requestwithurl:[nsurl urlwithstring:[nsstring stringwithformat:@"%@/%@", [[configloader config] objectforkey:@"server"], _entry.url]]]; [request setdownloaddestinationpath:[nsstring stringwithformat:@"%@/%@", documentsdirectorypath, _entry.filename]]; [request setentry:_entry]; [request setraw:_entry.title]; trainingentry * test = (trainingentry*)[request _entry]; nslog(@"title: %@", [test title]); //<= works nslog(@"filename: %@", [test filename]); //<= works [[self networkqueue] addoperation:request]; } // start queue [[self networkqueue] go]; ... - (void)requestfinished:(httprequest *)request { if ([[self networkqueue] requestscount] == 0) { [self setnetworkqueue:nil]; } nslog(@"req: %@", [request raw]); nslog(@"title: %@", [[request entry] title]); // <= works nslog(@"filename: %@", [[request entry] filename]); // <= crashes }
httprequest object
@interface httprequest : asihttprequest { } @property (nonatomic, retain) trainingentry * entry; @property (nonatomic, retain) nsstring * raw; @end
trainingentry class
@interface trainingentry : nsobject { nsstring * title; nsstring * filename; } @property (nonatomic, retain) nsstring * title; @property (nonatomic, retain) nsstring * filename;
something may giving trouble not having copy
in property declaration. should consider using copy
objects conform nscopying
protocol specification, nsstring
, other collection classes.
in past, changing retain
copy
nsstring
property solved similar issue me.
edit: research
this post may clarify why should use copy
on retain
immutable objects.
Comments
Post a Comment