I am having a crash I do not understand. I am downloading a couple files from a remote server, and when a file has finished downloading, I am attempting to retrieve an object that was attached to the request object.
Tia for any 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]); //<= This works
NSLog(@"filename: %@", [test filename]); //<= This 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]); // <= This works
NSLog(@"filename: %@", [[request entry] filename]); // <= This 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;