Jayant's Blog

Saturday, December 05, 2009

Inadvertently adding nil to NSArray

In Cocoa, when populating a NSArray, you use nil to mark the end of the objects being added. So lets say you were populating an array using values from 2 UITextfields and a property, such that:

NSArray *array = [NSArray arrayWithObjects:self.textField1.text, self.textField2.text, self.nsnumberProperty, nil];


The values populated at runtime would look something like:

NSArray *array = [NSArray arrayWithObjects:"foo", "bar", 10, nil];


When you print out the array you get: { "foo", "bar", 10 }.

But what happens, if say self.textField2.text is nil? Now the code at runtime would look like:

NSArray *array = [NSArray arrayWithObjects:"foo", nil, 10, nil];


When you print the array now: { "foo" }

Ouch! Noticed what happened there? The array was terminated by the first nil, so you may have expected 3 values, but you only got 1. So beware of inadvertently adding a nil and terminating a NSArray. Use [NSNull null] if you want to add a null object in an array. Arrays: Ordered Collections.

This is definitely the case in NSDictionary also, but not sure if this is the case in NSSet.

Sunday, August 09, 2009

Wow, need to post more often!

Life has been quite busy for the past 5 months. Released v1.4 of the JSAPI and got done with UC and the sessions there, but the big news is iPhone development.

I have been working on developing iPhone apps for a few months now, finally convinced the appropriate people, built a prototype app in 2 weeks that was showcased during the plenary session of the recently concluded User Conference. Check out the video: Plenary Session - 2009 ESRI User Conference -> 'ArcGIS 9.4: Mobile GIS' -> about 2/3rds way into the video, presented by Chris Capelli.

So now I am leading the development of the iPhone API, similar to the JavaScript API, and have handed over the reins to the JSAPI to Praveen. So finally I am getting to make my move into mobile computing.

Friday, February 27, 2009

ArcGIS JavaScript API v1.3 OUT

This is a developer centric release. The enhancements include custom layers, error handling and more layer management in the Map which have been requested time & time again. Check out the full list of What's New.

At the Dev Summit in March, Jeremy & I will be presenting the 'An overview of the ArcGIS JavaScript APIs' and 'Developing Advanced Applications with the ArcGIS JavaScript API' sessions. Jeremy will also be presenting 'Patterns and Best Practices for Building Applications with ArcGIS API for JavaScript' and finally 'Using the ArcGIS Server REST API' with Keyur. To see when these sessions are offered, go to the session search page and search by session name.

We will take an in-depth look into the v1.3 developer features in the advanced sessions. In depth looks into error handling, using esri.request, custom layer, etc. You can hear a podcast about our sessions too.

In case you are interested in attending for the ESRI Developer Summit, check out the website.

Saturday, February 07, 2009

Google Latitude & the iPhone

I'm sure everyone has heard about Google Latitude, essentially a mobile app that lets you share and find friends in the vicinity, with caveats. Well, what it may potentially tell us about the next iPhone OS release is that the OS will probably have background processes. I know its a long shot, but here goes:

The google latitude page states: http://google.com/latitude -> Will it work with my phone? -> iPhone and iPod touch devices (coming soon).

In the FAQ for Latitude: http://www.google.com/support/mobile/bin/answer.py?answer=136647&topic=20071, the page states:
  • ... Latitude can automatically detect and update your location in the background ...

  • ... you will have the option to continue sharing your location in the background even with Maps for mobile closed.


  • So in order for Latitude to truly work on the iPhone, they need background process support in the SDK. And guess what, it may be 'coming soon'. Fingers crossed & hoping so...

    Wednesday, December 31, 2008

    Integrating SVG in blogger post

    This is in response to a comment to my earlier post Integrating Dojo in blogger post.

    If you want to just use SVG, the following sample works. It uses 2 external JavaScript files, one for basic SVG context and drawing (also used in the Simple SVG Shapes post) and the 2nd one for actually drawing the content.


    Here is the HTML markup:

    <div id="surface" style="width:300px; height:300px; border:1px solid #000;"></div>
    <script type="text/javascript" src="http://ecodevil.net/dev/blog/svg.js"></script>
    <script type="text/javascript" src="http://ecodevil.net/dev/blog/blogger_svg.js"></script>

    I also tried with Dojo GFX. GFX is a nice abstraction layer to SVG/VML graphics. I tried integrating it into the blogger page, but that didn't worry, it kept throwing a console not found error. Here's the external JavaScript file incase you would like to try it.

    Labels: ,

    Friday, November 21, 2008

    ArcGIS JavaScript API v1.2 OUT

    We've worked on this for the last 3-4 months or so. Its a major release for us with a LOT of new features & updates.

    We have tried to keep the backward compatibility and we pretty much have it. Just a few minor things which are stricter, for example, setting an Extent in the Map constructor should have a SpatialReference and the SR and extent values should be in sync.

    Go check it out... the ArcGIS Server Blog post

    Labels: ,

    Wednesday, October 22, 2008

    Integrating Dojo in blogger post

    So I have been working on integrating Dojo within my blog... so here goes.


    So first, I should thank this blog post on integrating an external JavaScript module within a blogger post. So essentially all the work is done in an external file. But this document still contains the markup that the dojo parser parses to render the light box.

    Click on the 'Open lightbox' link below and it will open up a dojo lightbox. These are photos of a sunset I took while in Vancouver in August. Use the keyboard cursor keys to navigate through the photos.

    <div class="tundra">
    <a href="..." dojoType="dojox.image.Lightbox" group="sunset" title="A beautiful sunset">Open lightbox</a>
    <a href="..." dojoType="dojox.image.Lightbox" group="sunset" title="The colors where AMAZING"></a>
    <a href="..." dojoType="dojox.image.Lightbox" group="sunset" title="Taken from my friend's apartment"></a>
    <script type="text/javascript" src="http://ecodevil.net/dev/blog/blogger_lightbox.js"></script>
    </div>

    Thats it.

    Labels: