• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSURLDownload - multiple requests not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSURLDownload - multiple requests not working


  • Subject: NSURLDownload - multiple requests not working
  • From: Dalton Hamilton <email@hidden>
  • Date: Sun, 19 Aug 2007 11:11:50 -0400

I can download a single URL but if I try to "harvest" all urls out of that page and then download all of those, I never receive a CALLBACK for those called from my scanResults method below.

I receive a callback from the first (i.e. main URL) and the page is downloaded fine.  I pass the filename to a seperate thread (scanResults) which opens the file and tries to download every url in that page.  Again, I don't get a callback.  Any ideas why???  THANKS.

- (void)downloadDidFinish:(NSURLDownload *)download
{
NSEnumerator *e;
id object;

e=[urlArray objectEnumerator];
while ( object = [e nextObject] ) 
{    
    if([object objectForKey:@"nsurldownload"] == download)
{
float difference = [[NSDate date] timeIntervalSinceReferenceDate] - [[object objectForKey:@"startTime"] timeIntervalSinceReferenceDate];
[object setObject:[NSNumber numberWithFloat:difference]  forKey:@"latency"];
[downloadHistoryTV reloadData];

if([harvestSwitch state] == NSOnState)
{
if(currentPageCount < totalPagesPermitted)
[NSThread detachNewThreadSelector:@selector(scanResults:) toTarget:self withObject:[object objectForKey:@"filename"]];
}
}
}
    [download release];
}
-(IBAction)scanResults:(id)sender
{   
NSAutoreleasePool       *pool = [[NSAutoreleasePool alloc] init];


NSString *aRow;
NSString                                        *fileContents;
NSArray                                         *rowArray;
NSArray                                         *rowComponents;
NSString *pageFile;

fileContents = [NSString stringWithContentsOfFile:sender];

rowArray = [fileContents componentsSeparatedByString:@"\n"];
int i,rowCount = [rowArray count]; 
for(i=0;i<rowCount;i++)
{
aRow = [rowArray objectAtIndex:i];
rowComponents = [aRow componentsSeparatedByString:@"http://"];
if([rowComponents count] < 2)
continue;


NSString *tmpString = [NSString stringWithString:@"\""];
NSArray  *parseArray = [[rowComponents objectAtIndex:1] componentsSeparatedByString:tmpString];


NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:[parseArray objectAtIndex:0]]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSURLDownload  *theDownload=[[NSURLDownload alloc] initWithRequest:theRequest  delegate:self];
if (theDownload) 
{
pageFile = [[NSString alloc] initWithFormat:@"%@/%f",ironWebDir,[[NSDate date] timeIntervalSinceReferenceDate]];
[theDownload setDestination:pageFile     allowOverwrite:YES];
NSMutableDictionary         *record = [NSMutableDictionary dictionary];
[record setObject:theDownload forKey:@"nsurldownload"];
[record setObject:[parseArray objectAtIndex:0] forKey:@"url"];
[record setObject:[NSDate date]  forKey:@"startTime"];
[record setObject:pageFile forKey:@"filename"];


[urlArray addObject:record];
[downloadHistoryTV reloadData];
}
}
[pool release];
}


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSURLDownload - multiple requests not working
      • From: Dalton Hamilton <email@hidden>
  • Prev by Date: NSURLDownload - multiple requests not working
  • Next by Date: Re: NSURLDownload - multiple requests not working
  • Previous by thread: NSURLDownload - multiple requests not working
  • Next by thread: Re: NSURLDownload - multiple requests not working
  • Index(es):
    • Date
    • Thread