<?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: Pushing AGSEnvelope into NSUserDefaults in ArcGIS Runtime SDK for iOS Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/pushing-agsenvelope-into-nsuserdefaults/m-p/70251#M684</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is good, Divesh. Thank you for taking your time to work this out for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did not realize the usefulness of JSON and the methods in ArcGIS.h for working with JSON. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Much appreciated, sir.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Paul Lohr&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Jul 2012 10:23:00 GMT</pubDate>
    <dc:creator>PaulLohr</dc:creator>
    <dc:date>2012-07-03T10:23:00Z</dc:date>
    <item>
      <title>Pushing AGSEnvelope into NSUserDefaults</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/pushing-agsenvelope-into-nsuserdefaults/m-p/70248#M681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was trying to push an AGSEnvelope into NSUserDefaults:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //.h file&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @property (nonatomic) IBOutlet AGSMapView *mapView;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @property (nonatomic, strong) AGSEnvelope *mapExtent;&amp;nbsp; &amp;nbsp;&amp;nbsp; //.m file&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NSString *kMapExtent = @"mapExtent";&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; AGSPolygon *mapExtentPoly = self.mapView.visibleArea; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // see above...self.mapExtent is of type AGSEnvelope &amp;nbsp;&amp;nbsp;&amp;nbsp; self.mapExtent = mapExtentPoly.envelope; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // this is key to the problem...attempt to convert AGSEnvelope so it can be used as NSData in NSUserDefaults. &amp;nbsp;&amp;nbsp;&amp;nbsp; self.dataForMapExtent = [NSKeyedArchiver archivedDataWithRootObject:self.mapExtent]; &amp;nbsp;&amp;nbsp; // the program crashes after this line is run&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [defaults setObject:self.dataForMapExtent forKey:kMapExtent]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [defaults synchronize];&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the error message I get when the program crashes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;[AGSEnvelope encodeWithCoder:]: unrecognized selector sent to instance&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think Apple's classes that inherit from NSCoding can convert themselves to NSData. I see that AGSEnvelope inherits from AGSCoding but it looks to only encode/decode JSON. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do I need to convert the AGSEnvelope to something like an NSDictionary before putting it into NSUserDefaults? Is this the best solution?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Paul Lohr&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jun 2012 18:26:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/pushing-agsenvelope-into-nsuserdefaults/m-p/70248#M681</guid>
      <dc:creator>PaulLohr</dc:creator>
      <dc:date>2012-06-28T18:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Pushing AGSEnvelope into NSUserDefaults</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/pushing-agsenvelope-into-nsuserdefaults/m-p/70249#M682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I ended up putting AGSEnvelope.xmin, xmax, ymin, and ymax into double data type variables, I then put the doubles into an NSDictionary, then I put the NSDictionary into an NSUserDefaults variable. That's a handful of steps but it works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In case you missed it or I was unclear, the problem was that AGSEnvelope could not be put into an NSData variable. I wanted to do this because NSData will go directly into an NSUserDefaults variable. This is a little cleaner than going to a double.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps there is a way to get AGSEnvelope to inherit from NSCoding but I don't know how that would be done. If AGSEnvelope implemented NSCoding's encodeWithEncoder, AGSEnvelope could be put directly into an NSData variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you can help with this, I'd appreciate it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Paul Lohr&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 Jun 2012 07:28:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/pushing-agsenvelope-into-nsuserdefaults/m-p/70249#M682</guid>
      <dc:creator>PaulLohr</dc:creator>
      <dc:date>2012-06-30T07:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Pushing AGSEnvelope into NSUserDefaults</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/pushing-agsenvelope-into-nsuserdefaults/m-p/70250#M683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Paul,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NSUserDefaults can also accept objects of type NSString.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As you noted, most AGS* objects implement AGSCoding protocol. This protocol defines how objects can be converted to and from JSON.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What you will basically need to do is, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) convert AGSEnvelope to a JSON representation (dictionary), and&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) string-ify the JSON representation. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can then store this string into NSUserDefaults&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can find more info &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/runtime-ios-sdk/concepts/index.html#/Working_with_JSON/00pw0000004w000000/" rel="nofollow" target="_blank"&gt;here&lt;/A&gt;&lt;SPAN&gt;. (Refer to the 'ArcGIS classes are JSON friendly section').&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 14:36:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/pushing-agsenvelope-into-nsuserdefaults/m-p/70250#M683</guid>
      <dc:creator>DiveshGoyal</dc:creator>
      <dc:date>2012-07-02T14:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Pushing AGSEnvelope into NSUserDefaults</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/pushing-agsenvelope-into-nsuserdefaults/m-p/70251#M684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is good, Divesh. Thank you for taking your time to work this out for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did not realize the usefulness of JSON and the methods in ArcGIS.h for working with JSON. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Much appreciated, sir.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Paul Lohr&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jul 2012 10:23:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/pushing-agsenvelope-into-nsuserdefaults/m-p/70251#M684</guid>
      <dc:creator>PaulLohr</dc:creator>
      <dc:date>2012-07-03T10:23:00Z</dc:date>
    </item>
  </channel>
</rss>

