Trouble with AGSAttachmentManagerDelegate

438
1
11-15-2012 12:29 PM
DanielMonego
New Contributor II
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];
}

0 Kudos
1 Reply
DiveshGoyal
Esri Regular Contributor
Can you try doing this :


-(void)attachmentManager:(AGSAttachmentManager *)attachmentManager didDownloadAttachmentInfos:(NSArray *)attachmentInfos
{
    for(AGSAttachmentInfo *info in attachmentInfos)
    {
        [attachmentManager downloadAttachmentDataForId:info.attachmentId];
    }
}
0 Kudos