dmonego

Trouble with AGSAttachmentManagerDelegate

Discussion created by dmonego on Nov 15, 2012
Latest reply on Nov 19, 2012 by DGoyal-esristaff
I'm having some trouble with the AGSAttachmentManager downloading attachments. The following methods are all in a ViewController that implements AGSAttachmentManagerDelegate, but when it runs, the delegate methods don't fire. I've tried adding calls to retain, in case it was an issue with the manager getting prematurely cleaned up, but that doesn't appear to be what's happening. This happens with calls to a feature that definitely has an attachment visible in REST.

Is there a reason why the first function in this code would run but the second two wouldn't?

-(void)setSelectedGraphic:(AGSGraphic *)selectedGraphicValue
{
    _selectedGraphic = selectedGraphicValue;
    [self.relatedTableFeatureLayer clearAttachmentManagers];
    AGSAttachmentManager *am = [[self.relatedTableFeatureLayer attachmentManagerForFeature:_selectedGraphic] retain];
    am.delegate = self;
    [am downloadAttachmentInfos];
}


-(void)attachmentManager:(AGSAttachmentManager *)attachmentManager didDownloadAttachmentInfos:(NSArray *)attachmentInfos
{
    for(InspectionFormViewController *controller in self.viewControllers)
    {
        controller.attachments = [NSMutableArray array];
    }
    for(AGSAttachmentInfo *info in attachmentInfos)
    {
        AGSAttachmentManager *am = [[self.relatedTableFeatureLayer attachmentManagerForFeature:self.selectedGraphic] retain];
        am.delegate = self;
        [am downloadAttachmentDataForId:info.attachmentId];
    }
    //[attachmentManager release];
}

-(void)attachmentManager:(AGSAttachmentManager *)attachmentManager didDownloadDataForAttachment:(AGSAttachment *)attachment
{
    for(InspectionFormViewController *controller in self.viewControllers)
    {
        [controller.attachments addObject:attachment];
    }
    //[attachmentManager release];
}

Outcomes