<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Copying a Graphic iOS in ArcGIS Runtime SDK for iOS Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/copying-a-graphic-ios/m-p/363455#M3124</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Kyle,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not really sure how do you want to arrange the two graphics display on the map. But ideally, each AGSGraphic should point to specific geometry, then based on the geometry you can associate the graphic to this unique Global ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example if you check &lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_graphic.html#a75a7126baf60cd2ffddeaf0d1e8254ed" title="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_graphic.html#a75a7126baf60cd2ffddeaf0d1e8254ed"&gt;10.2.3: AGSGraphic Class Reference&lt;/A&gt;&amp;nbsp; , it says "Only the geometry argument is mandatory." Therefore, I think you we using initWithJSON method, you suppose to do the same thing in order to make the graphic associate to specific Global ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example this is snippet:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14091755428539104 jive_text_macro" jivemacro_uid="_14091755428539104"&gt;
&lt;P&gt;AGSGraphic *pinGraphic = [AGSGraphic graphicWithGeometry:pt symbol:pinSymbol attributes:nil infoTemplateDelegate:nil];&lt;/P&gt;



&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, have you checked with this thread yet? This thread might give you some ideas as well.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/46243"&gt;Update AGSFeatureLayer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this can help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Aug 2014 21:38:38 GMT</pubDate>
    <dc:creator>YueWu1</dc:creator>
    <dc:date>2014-08-27T21:38:38Z</dc:date>
    <item>
      <title>Copying a Graphic iOS</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/copying-a-graphic-ios/m-p/363454#M3123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Im having weird issues with copying graphics.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AGSGraphic *first = .....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AGSGraphic *second = [[AGSGraphic alloc] initWithJSON:[first encodeToJSON];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I change some of the attributes of both first and second, update first, and add second to the feature layer, because second has the same globalID as first, I get two instances of the first graphic on the feature layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I check the database, the features are all correct, and the second graphic did get added and the first got updated correctly.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to reload the layers in the app to see the changes.&amp;nbsp; Any ideas what could be going wrong?&lt;/P&gt;&lt;P&gt;I checked the graphics, when i copy the first graphic and make a copy/second graphic they have the same globalID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 20:37:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/copying-a-graphic-ios/m-p/363454#M3123</guid>
      <dc:creator>KyleDunaway</dc:creator>
      <dc:date>2014-08-27T20:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: Copying a Graphic iOS</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/copying-a-graphic-ios/m-p/363455#M3124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Kyle,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not really sure how do you want to arrange the two graphics display on the map. But ideally, each AGSGraphic should point to specific geometry, then based on the geometry you can associate the graphic to this unique Global ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example if you check &lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_graphic.html#a75a7126baf60cd2ffddeaf0d1e8254ed" title="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_graphic.html#a75a7126baf60cd2ffddeaf0d1e8254ed"&gt;10.2.3: AGSGraphic Class Reference&lt;/A&gt;&amp;nbsp; , it says "Only the geometry argument is mandatory." Therefore, I think you we using initWithJSON method, you suppose to do the same thing in order to make the graphic associate to specific Global ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example this is snippet:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14091755428539104 jive_text_macro" jivemacro_uid="_14091755428539104"&gt;
&lt;P&gt;AGSGraphic *pinGraphic = [AGSGraphic graphicWithGeometry:pt symbol:pinSymbol attributes:nil infoTemplateDelegate:nil];&lt;/P&gt;



&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, have you checked with this thread yet? This thread might give you some ideas as well.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/46243"&gt;Update AGSFeatureLayer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this can help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 21:38:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/copying-a-graphic-ios/m-p/363455#M3124</guid>
      <dc:creator>YueWu1</dc:creator>
      <dc:date>2014-08-27T21:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: Copying a Graphic iOS</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/copying-a-graphic-ios/m-p/363456#M3125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Displaying the graphic isn't the problem I am having.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is when I update the graphic, the copy is getting updated as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AGSGraphic *one = [[AGSGraphic alloc] init];&lt;/P&gt;&lt;P&gt;[one setAttribute:@"foo" forKey:@"Name"];&lt;/P&gt;&lt;P&gt;AGSGraphic *two = [[AGSGraphic alloc] initWithJSON:[one encodeToJSON];&lt;/P&gt;&lt;P&gt;[two setAttribute:@"bar" forKey@"Name"];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[featureLayer addGraphic:two];&lt;/P&gt;&lt;P&gt;[featureLayer addFeatures:@[two];&lt;/P&gt;&lt;P&gt;[featureLayer updatesFeatures:@[one]];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I check featureLayer.graphics I have two copies for one, and no two graphic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I check the database, two is there.&lt;/P&gt;&lt;P&gt;If I close the app, and reload the webMap, into mapView, and get the layer again, the graphics are correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Im just confused on why I have two copies and one, and how I avoid this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried [featureLayer refresh] to no avail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 21:54:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/copying-a-graphic-ios/m-p/363456#M3125</guid>
      <dc:creator>KyleDunaway</dc:creator>
      <dc:date>2014-08-27T21:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Copying a Graphic iOS</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/copying-a-graphic-ios/m-p/363457#M3126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you use encodeToJSON, all the information of the graphic is serialized into json, including some attributes such as ObjectID and GlobalID which are supposed to be unique to each graphic. When you use this json to hydrate a new instance of the graphic, the same IDs are used which could cause problems. You should nil out these attributes of the new graphic before adding it to the layer. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Aug 2014 16:36:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/copying-a-graphic-ios/m-p/363457#M3126</guid>
      <dc:creator>DiveshGoyal</dc:creator>
      <dc:date>2014-08-28T16:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Copying a Graphic iOS</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/copying-a-graphic-ios/m-p/363458#M3127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ahh, that would make sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It was an interesting error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would addGraphic, addFeature, updateFeature in that order and sometimes the add would work, and sometimes the update would overwrite it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ended up making a new graphic, and assigning the attributes one by one as I was getting frustrated.&lt;/P&gt;&lt;P&gt;If I decide to fix this, I should do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AGSGraphic *new = [[AGSGraphic alloc] initWithJSON:[old encodeToJSON];;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;new setAttributeToNullForKey:[@"GlobalId"]; and OBJECTID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the reply&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Aug 2014 16:53:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/copying-a-graphic-ios/m-p/363458#M3127</guid>
      <dc:creator>KyleDunaway</dc:creator>
      <dc:date>2014-08-28T16:53:47Z</dc:date>
    </item>
  </channel>
</rss>

