Copying Attributes from one Graphic to another

2221
3
Jump to solution
08-22-2013 02:10 PM
JeffGiesler
Occasional Contributor
Hey Everyone,
I am trying to transfer attributes from one graphic to another.  When I run it, it seems like it is going to work.  The attributes in the popup look are the ones I am trying to copy.  When I refresh the map the attributes revert back to the old ones.  I don't know what I am missing.  This worked before I upgraded to 10.0.1 sdk, minus the changes to the setAllAttributes.
Cheers,
Jeff
Code Posted below
Where I assign the attributes
-(void) DoneAssociatingFeatures {     NSNumber *numberSketch = [NSNumber numberWithInteger:[self.activeFeatureLayer objectIdForFeature:GraphictoEdit]];     for (AGSGraphic *graphic in self.activeFeatureLayer.graphics)     {         NSNumber *number = [NSNumber numberWithInteger:[self.activeFeatureLayer objectIdForFeature:graphic]];         AGSGeometryEngine *geometryEngine = [AGSGeometryEngine defaultGeometryEngine];         if ([geometryEngine geometry:self.editGeometrySketchGraphicsLayer.geometry withinGeometry:graphic.geometry])         {              if ([numberSketch isEqualToNumber:number]){}             else             {                 for (id key in graphic.allAttributes)                 {                     if (![key isEqual: @"OBJECTID"])                     {                         id value = [graphic.allAttributes objectForKey:key];                         NSLog(@"Graphic Value %@",value);                         [self.popupVC.currentPopup.graphic setAttribute:value forKey:key];                     }                 }             }         }     }     [self presentModalViewController:self.popupVC animated:YES];     self.mapView.touchDelegate = self;     [self.editGeometrySketchGraphicsLayer clear]; }

Finished editing graphic
-(void) popupsContainer:(id<AGSPopupsContainer>)popupsContainer didFinishEditingGraphicForPopup:(AGSPopup *)popup {     [self.bezierImageView removeFromSuperview];     self.activeFeatureLayer = (AGSFeatureLayer*) popup.featureLayer;     popup.graphic.geometry = [[AGSGeometryEngine defaultGeometryEngine]simplifyGeometry:popup.graphic.geometry];     popup.graphic.geometry = [[AGSGeometryEngine defaultGeometryEngine]normalizeCentralMeridianOfGeometry:popup.graphic.geometry];     int oid = [self.activeFeatureLayer objectIdForFeature:popup.graphic];     if(oid >0)     {         //Has valid oid and is only updated on server         [self.activeFeatureLayer updateFeatures:[NSArray arrayWithObject:popup.graphic]];     }     else     {         // does not have valid oid and is add as a new feature         [self.activeFeatureLayer addFeatures:[NSArray arrayWithObject:popup.graphic]];     }     if (AppDelagate.ActiveProject != nil)     {         if ([popup.graphic.geometry isEqual:AppDelagate.ActiveProject.geometry])         {             AppDelagate.ActiveProject.allAttributes = popup.graphic.allAttributes;         }     }     [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];   }  
0 Kudos
1 Solution

Accepted Solutions
JeffGiesler
Occasional Contributor
Figured it out.  It was the GlobalID field that was causing the problem,  probably more so that it is uneditable and I was apparently trying to edit it.
Jeff

View solution in original post

0 Kudos
3 Replies
DiveshGoyal
Esri Regular Contributor
When you say "when I refresh the map the attributes revert back to the old ones", how are you refreshing the map?

I noticed you are calling [self.activeFeatureLayer updateFeatures:[NSArray arrayWithObject:popup.graphic]]; to update the feature on the server. Can you inspect the attributes of the graphic right before this method to ensure that the attributes are still what you expect.

Also, does the editingDelegate of the feature layer report that the edits were successfully applied on the server?
0 Kudos
JeffGiesler
Occasional Contributor

Divesh,
I checked the attributes and they are as expected.  I probably should have put
the DidFeatureEditsWithResults method in earlier.  I am getting an error in the description comes up as <AGSEditResultsError: 0x98a7790> and a code of 0x000003e8.  I don"t know what this means. 
Cheers,
Jeff

0 Kudos
JeffGiesler
Occasional Contributor
Figured it out.  It was the GlobalID field that was causing the problem,  probably more so that it is uneditable and I was apparently trying to edit it.
Jeff
0 Kudos