<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Radu Poenaru &#187; CSCW Lab- iPhone</title>
	<atom:link href="http://www.radupoenaru.com/category/media-informatics/cscw-lab-iphone/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.radupoenaru.com</link>
	<description>Team leader and Software engineer</description>
	<lastBuildDate>Mon, 01 Aug 2011 20:47:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>iMeet application presentation</title>
		<link>http://www.radupoenaru.com/imeet-application-presentation/</link>
		<comments>http://www.radupoenaru.com/imeet-application-presentation/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 17:50:00 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[CSCW Lab- iPhone]]></category>
		<category><![CDATA[Fraunhofer FIT]]></category>
		<category><![CDATA[Interface Buider]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Media Informatics]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[RWTH Aachen]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/imeet-application-presentation/</guid>
		<description><![CDATA[iMeet application is ready.  I am very proud of this application, as it represents my achievements in fast learning and adapting to: new way of programming, as XCode and Interface Builder truly represent the ModelViewController paradigm; new language- Objective-C, which as any language has its pluses and minuses; new device: mobile devices on which I didn’t work since my experience on Sales Force Automation in TotalSoft company, back in 2005, on Windows CE.<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/imeet-application-presentation/">iMeet application presentation</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fimeet-application-presentation%2F' data-shr_title='iMeet+application+presentation'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fimeet-application-presentation%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fimeet-application-presentation%2F' data-shr_title='iMeet+application+presentation'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fimeet-application-presentation%2F' data-shr_title='iMeet+application+presentation'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/imeet_icon.png"><img width="57" height="57" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/imeet_icon_thumb.png" alt="iMeet logo icon" title="iMeet logo icon" style="border-width: 0px; margin: 10px; display: inline;" /></a> Finally, the biggest moment: application is ready!! I am very proud of this application, as it represents my achievements in fast learning and adapting to:</p>
<ul>
<li>new way of programming, as XCode and Interface Builder truly represent the ModelViewController paradigm</li>
<li>new language- Objective-C, which as any language has its pluses and minuses</li>
<li>new device: mobile devices on which I didn&rsquo;t work since my experience on Sales Force Automation in TotalSoft company, back in 2005, on Windows CE.</li>
</ul>
<p>I&rsquo;ve structured the application visually in few areas:</p>
<p><strong>1. Login screen</strong> &ndash; the &#8216;&rdquo;gate&rdquo; to the application. Since the access to the<strong><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/Picture1.png"><img width="129" height="240" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/Picture1_thumb.png" alt="iMeet - first screen, allowing login with credentials on a specific webserver" title="iMeet - first screen, allowing login with credentials on a specific webserver" style="border-width: 0px; margin: 10px 0px; display: inline;" /></a></strong></p>
<p>XML-RPC is done in a secure way, the application implemented also a credential input and recording mechanism. The mechanism is dual: user can enter the login into the first screen or in the iPhone Settings application. Depends only on him where and how he&rsquo;ll manage his credentials.</p>
<p>&nbsp;</p>
<p>The main point of this screen is to create a intuitive interface for users to insert their credentials, instead of having to leave the application and go to the iPhone settings.</p>
<p><span id="more-634"></span></p>
<p>&nbsp;</p>
<p><font color="#eeeeee"><strong>2. Meetings view &ndash; </strong></font>presenting the today and tomorrow meetings(the leftmost picture), keeping user on a focused view. No clutter, nice design &ndash; what can be more appealing? Also there is a Log out button, allowing users to switch between meeting servers.</p>
<p>Of course, on clicking on a row, you&rsquo;ll be able to quickly see the details of the meeting(picture in the middle), accept or reject it, see the participants of the meeting and of course the map to the meeting(the rightmost picture) which Search bar is in read-only mode, because this location can&rsquo;t be edited, only viewed:</p>
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tbody>
<tr>
<td valign="top"><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/Picture8.png"><img width="129" height="240" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/Picture8_thumb.png" alt="Main view of the application, showing the meetings grouped and categorized by icons" title="Main view of the application, showing the meetings grouped and categorized by icons" style="border-width: 0px; margin: 10px 0px; display: inline;" /></a></td>
<td valign="top"><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/Picture9.png"><img width="129" height="240" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/Picture9_thumb.png" alt="iMeet- IPhone shows a clear and crisp meeting detail." title="iMeet- IPhone shows a clear and crisp meeting detail." style="border-width: 0px; margin: 10px 0px; display: inline;" /></a></td>
<td valign="top"><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/Picture6.png"><img width="129" height="240" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/Picture6_thumb.png" alt="Seeing a map of the chosen location for meeting" title="Seeing a map of the chosen location for meeting" style="border-width: 0px; margin: 10px 0px; display: inline;" /></a></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><font color="#eeeeee"><strong>3. Add meeting &ndash; </strong></font>structured as a wizard, allows user to create, following some simple steps the&nbsp; desired meeting. As you might probably get used, the User interface is nicely designed, inviting you to create a meeting <img src='http://www.radupoenaru.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . The steps are:<font color="#efefef"><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/Picture3.png"><img width="129" height="240" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/Picture3_thumb.png" alt="iMeet- compose a new meeting" title="iMeet- compose a new meeting" style="border-width: 0px; margin: 10px 30px 10px 10px; display: inline;" /></a></font></p>
<ul>
<li><font color="#efefef">choose your type of meeting</font></li>
<li><font color="#efefef">Setup the most important details: title, description and location</font>
<ul>
<li><font color="#efefef">Location can be previewed as you click on the pin button</font></li>
</ul>
</li>
<li><font color="#efefef">Start and end time of meeting, keeping iPhone&rsquo;s own locale system</font>
<ul>
<li><font color="#efefef">using locale set into iPhone date and time,</font></li>
<li><font color="#efefef">default and intuitive way to select date and time</font></li>
<li><font color="#efefef">in the bottom there are set the start and end date, allowing user to quickly remember and check their correctness</font></li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<p><strong>4. View Meetings &ndash; </strong>shows to the user an extended view of older / next <a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/Picture13.png"><img width="129" height="240" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/Picture13_thumb.png" alt="iMeet - Show the older meetings." title="iMeet - Show the older meetings." style="border-width: 0px; margin: 10px; display: inline;" /></a> meetings, so he&rsquo;ll be focused on what meeting he&rsquo;s looking for. And of course, a meeting detail is available as well.</p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/imeet-application-presentation/">iMeet application presentation</a></p>
<div class="shr-publisher-634"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/imeet-application-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C: Putting markers on Map control</title>
		<link>http://www.radupoenaru.com/objective-c-putting-markers-on-map-control/</link>
		<comments>http://www.radupoenaru.com/objective-c-putting-markers-on-map-control/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 22:35:00 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[CSCW Lab- iPhone]]></category>
		<category><![CDATA[Interface Buider]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Media Informatics]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[RWTH Aachen]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/objective-c-putting-markers-on-map-control/</guid>
		<description><![CDATA[Adding the points to the map is not as intuitive as it might seem, so let’s start by creating a new class called POI – point of interest. Assuming that we have the Latitude and Longitude as NSStrings, we check if they are filled. Then I create the CLLocationCoordonate2D which basically is a tuple of two doubles and then create the point of interest.<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/objective-c-putting-markers-on-map-control/">Objective-C: Putting markers on Map control</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-putting-markers-on-map-control%2F' data-shr_title='Objective-C%3A+Putting+markers+on+Map+control'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-putting-markers-on-map-control%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-putting-markers-on-map-control%2F' data-shr_title='Objective-C%3A+Putting+markers+on+Map+control'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-putting-markers-on-map-control%2F' data-shr_title='Objective-C%3A+Putting+markers+on+Map+control'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode7.png"><img width="240" height="240" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode_thumb7.png" alt="xcode" title="xcode" style="border-width: 0px; margin: 10px; display: inline;" /></a></p>
<p>This article comes as a completion to my previous ones, <a href="http://www.radupoenaru.com/xcode-using-mapkit-with-no-geocoding-available-out-of-the-box/">XCode : using MapKit with no geocoding available out of the box</a> and <a href="http://www.radupoenaru.com/xcode-modal-windows-google-maps/">XCode: Modal windows &ndash; Google maps</a> and shows how to add pins on your already created Map View.</p>
<p>First of all, adding the points to the map is not as intuitive as it might seem, so let&rsquo;s start by creating a new class called POI &ndash; point of interest. Its header must be filled with this code:</p>
<p>&nbsp;</p>
<pre class="brush:objc;">
#import &lt;foundation foundation.h&gt;
#import &lt;mapkit mapkit.h&gt;
#import &lt;corelocation corelocation.h&gt;

@interface POI : NSObject <mkannotation> {    CLLocationCoordinate2D coordinate;        NSString *subtitle;         NSString *title;     }

@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;@property (nonatomic,retain) NSString *subtitle;@property (nonatomic,retain) NSString *title;- (id) initWithCoords:(CLLocationCoordinate2D) coords;

@end</mkannotation></pre>
<p><span id="more-617"></span></p>
<p>And the implementation should look like this:</p>
<pre class="brush: objc;">
#import &quot;POI.h&quot;

@implementation POI
@synthesize coordinate;
@synthesize subtitle;
@synthesize title;

- (id) initWithCoords:(CLLocationCoordinate2D) coords{
    self = [super init];

    if (self != nil)
        coordinate = coords;

    return self;
}

- (void) dealloc{
    [title release];
    [subtitle release];
    [super dealloc];
}

@end</pre>
<p>Then, adding the point is quite easy, as you can see in the following code snippet. Assuming that we have the Latitude and Longitude as NSStrings, we check if they are filled. Then I create the CLLocationCoordonate2D which basically is a tuple of two doubles and then create the point of interest. I could have set also its title and description. Then I removed all annotations already existing, because this map will show only one point.</p>
<p>The next thing that I set was the region &#8211; MKCoordinateRegion and span of the view MKCoordinateSpan constructs, which are very intuitive so I will not dig deeper into them.</p>
<p>Finally, by using setRegion method of my map control I set the already filled MKCoordinateRegion and set that the transition and zoom should be animated, to give a nice diving effect. improving user experience. Finally, I tell to the control that it should show only the region of the map that fits my specific area, controlling this way the amount of visual information showed to the user.</p>
<p>Else, if they are 0 I throw an alert to the user.</p>
<pre class="brush: objc;">
if (!([Latitude isEqualToString:@&quot;0&quot;] || [Longitude isEqualToString:@&quot;0&quot;] )){
    NSLog(Latitude) ; NSLog(Longitude);
    CLLocationCoordinate2D pinlocation;
    pinlocation.latitude = [Latitude doubleValue];
    pinlocation.longitude  = [Longitude doubleValue];
    POI *poi = [[POI alloc] initWithCoords:pinlocation];
    [mapkitView removeAnnotations:[mapkitView annotations]];
    [mapkitView addAnnotation:poi];
    [poi release];

    /*Region and Zoom*/
    MKCoordinateRegion region;
    MKCoordinateSpan span;
    span.latitudeDelta= 0.02;
    span.longitudeDelta= 0.02;

    region.span=span;
    region.center=pinlocation;

    [mapkitView setRegion:region animated:TRUE];
    [mapkitView regionThatFits:region];
}else{
    UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@&quot;Can't find address!&quot; message:@&quot;Sorry, the address you input can't be located.Please try another one.&quot;  delegate:self cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil];
    [errorAlert show];
}</pre>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/objective-c-putting-markers-on-map-control/">Objective-C: Putting markers on Map control</a></p>
<div class="shr-publisher-617"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/objective-c-putting-markers-on-map-control/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XCode: Modal windows &#8211; Google maps</title>
		<link>http://www.radupoenaru.com/xcode-modal-windows-google-maps/</link>
		<comments>http://www.radupoenaru.com/xcode-modal-windows-google-maps/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 07:20:00 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[CSCW Lab- iPhone]]></category>
		<category><![CDATA[My work]]></category>
		<category><![CDATA[Cocoa Touch]]></category>
		<category><![CDATA[Interface Buider]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Media Informatics]]></category>
		<category><![CDATA[Modal windows]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[RWTH Aachen]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/xcode-modal-windows-google-maps/</guid>
		<description><![CDATA[From time to time, you&#8217;ll need to show in your iPhone application a view over the entire application without navigating and destroying your workflow of the application. I&#8217;ll present the mechanism of modal windows as it is implemented in Cocoa Touch. Lets take a real case: you have a view in which you want to&#8230;<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/xcode-modal-windows-google-maps/">XCode: Modal windows &ndash; Google maps</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fxcode-modal-windows-google-maps%2F' data-shr_title='XCode%3A+Modal+windows+%26ndash%3B+Google+maps'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fxcode-modal-windows-google-maps%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fxcode-modal-windows-google-maps%2F' data-shr_title='XCode%3A+Modal+windows+%26ndash%3B+Google+maps'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fxcode-modal-windows-google-maps%2F' data-shr_title='XCode%3A+Modal+windows+%26ndash%3B+Google+maps'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode3.png"><img width="240" height="240" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode_thumb3.png" alt="xcode" title="xcode" style="border: 0px none ; margin: 10px 0px; display: inline;" /></a> From time to time, you&rsquo;ll need to show in your iPhone application a view over the entire application without navigating and destroying your workflow of the application. I&rsquo;ll present the mechanism of modal windows as it is implemented in Cocoa Touch.</p>
<p>Lets take a real case: you have a view in which you want to input an address. Near the address you have a button which will show the user the Map centered on the specific address that he inputted. How this can be implemented?</p>
<p>The answer is quite simple: you need to declare the view <strong>from which you launch the modal view</strong> as &lt;UINavigationBarDelegate&gt; in the header file (.h for newbies), like this:</p>
<pre class="brush: cpp;">
@interface CtrlAddEvtView1 : UIViewController &lt;UINavigationBarDelegate&gt;</pre>
<p>This way, the view will know &ldquo;magically&rdquo; how to interact with children views.</p>
<p><span id="more-590"></span></p>
<p>Next we need to create the IBAction (the exposed action for linking to a button action in Interface Builder) in the header file :</p>
<pre class="brush: cpp;">
- (IBAction) showMap:(id)sender;</pre>
<p>Now we&rsquo;ll move into the implementation file (corresponding .m file) and use the following code for calling our new view:</p>
<pre class="brush: cpp;">
-(IBAction)showMap:(id)sender{
    // create the modal view
    CtrlMapView *modalViewController = [[CtrlMapView alloc] initWithNibName:@&quot;MapView&quot; bundle:nil];

    // present info page as a modal view
    [[self navigationController] presentModalViewController:modalViewController animated:YES];
}  </pre>
<p>Next thing that needs to be done is to link a button from the Interface Builder on the view from which you want to launch the new one and link it to the showMap action.</p>
<p><strong>To return from the newly opened modal view</strong> we will need to create another action in its header file:</p>
<pre class="brush: cpp;">
- (IBAction)btnCancelClick:(id) sender;</pre>
<p>The implementation file will of course hold the implementation of the above method:</p>
<pre class="brush: cpp;">
- (IBAction)btnCancelClick:(id) sender{
    [[self parentViewController] dismissModalViewControllerAnimated:TRUE];
}</pre>
<p>&nbsp;</p>
<p>And that&#8217;s it, folks! Enjoy!</p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/xcode-modal-windows-google-maps/">XCode: Modal windows &ndash; Google maps</a></p>
<div class="shr-publisher-590"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/xcode-modal-windows-google-maps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XCode : using MapKit with no geocoding available out of the box</title>
		<link>http://www.radupoenaru.com/xcode-using-mapkit-with-no-geocoding-available-out-of-the-box/</link>
		<comments>http://www.radupoenaru.com/xcode-using-mapkit-with-no-geocoding-available-out-of-the-box/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 17:05:00 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[CSCW Lab- iPhone]]></category>
		<category><![CDATA[Interface Buider]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Media Informatics]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/xcode-using-mapkit-with-no-geocoding-available-out-of-the-box/</guid>
		<description><![CDATA[One of the tasks in the CSCW lab was to create a map on which the users to see the location of a specific address. So I started working on it, knowing that the newest framework brings a lot of goodies, through which there is also a map framework. But surprise! Apple provides only reverse&#8230;<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/xcode-using-mapkit-with-no-geocoding-available-out-of-the-box/">XCode : using MapKit with no geocoding available out of the box</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fxcode-using-mapkit-with-no-geocoding-available-out-of-the-box%2F' data-shr_title='XCode+%3A+using+MapKit+with+no+geocoding+available+out+of+the+box'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fxcode-using-mapkit-with-no-geocoding-available-out-of-the-box%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fxcode-using-mapkit-with-no-geocoding-available-out-of-the-box%2F' data-shr_title='XCode+%3A+using+MapKit+with+no+geocoding+available+out+of+the+box'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fxcode-using-mapkit-with-no-geocoding-available-out-of-the-box%2F' data-shr_title='XCode+%3A+using+MapKit+with+no+geocoding+available+out+of+the+box'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode2.png"><img width="240" height="240" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode_thumb2.png" alt="xcode" title="xcode" style="border-width: 0px; margin: 10px; display: inline;" /></a></p>
<p>One of the tasks in the CSCW lab was to create a map on which the users to see the location of a specific address.</p>
<p>So I started working on it, knowing that the newest framework brings a lot of goodies, through which there is also a map framework. But surprise! Apple provides only reverse geocoding, not forward geocoding. This means that you can only transform a pair of Latitude / Longitude to the Map and it will show it to the user. But what to do when user enters an address?</p>
<p>My point is that nobody caries with him a GPS to search for the address, get the coordinates and enter them into my map!</p>
<p>I was curious about it and after a little search I found that there was a big argue about the geocoding and Apple didn&rsquo;t want to pay the price that Google and Tom-Tom asked for this feature.</p>
<p><span id="more-580"></span></p>
<p>So I pursue in searching how to integrate geocoding into my application using free end-user services,like Google maps, Yahoo maps and other services alike. I finally settled to Yahoo because it was a RESTful service &ndash; requiring just a URL composed on some basic rules.</p>
<p>First, lets us set some helper variables :</p>
<pre class="brush: cpp;">
//the latitude and longitude as strings
NSString *Latitude, *Longitude;

//the parser state - required because we need to know what above variable to fill
NSString *State;</pre>
<p>Composing the URL is quite simple, it requires only to change YOUR_APPID with your one, <a href="https://developer.yahoo.com/wsregapp/">obtained from Yahoo</a>:</p>
<pre class="brush: cpp;">
NSString *strTemp = [[strTemp stringByReplacingOccurrencesOfString:@&quot;,&quot; withString:@&quot;&quot;] stringByReplacingOccurrencesOfString:@&quot; &quot; withString:@&quot;+&quot;];
NSString *URL = [NSString stringWithFormat: @&quot;http://local.yahooapis.com/MapsService/V1/geocode?appid=YOUR_APPID&amp;location=%@&quot;,
						   strTemp];

NSURL* url = [NSURL URLWithString:URL];
// fill the parser with the contens of the reply
NSXMLParser* parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[parser setDelegate:self];

State = @&quot;&quot;;

// Parser, get to work!
[parser parse];

//here the code returns from parsing and you can use the Longitude and Latitude variables already set</pre>
<p>The result of the query for Schloss Birlinghoven (the location of Fraunhofer FIT) looks like this: <resultset xsi:schemalocation="urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd"></p>
<pre>
&lt;resultset xsi:schemalocation=&quot;urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd&quot;&gt;
    &lt;result precision=&quot;street&quot;&gt;
        &lt;latitude&gt;50.748930&lt;/latitude&gt;
        &lt;longitude&gt;7.221640&lt;/longitude&gt;
        &lt;address&gt;Schlossstrasse&lt;/address&gt;
        &lt;city&gt;53757 Sankt Augustin&lt;/city&gt;
        &lt;state&gt;Germany&lt;/state&gt;
        &lt;zip /&gt;
        &lt;country&gt;DE&lt;/country&gt;
    &lt;/result&gt;
&lt;/resultset&gt;</pre>
<p>And the parser methods, required because you need to handle the delegated events of NSXMLParser:</p>
<pre class="brush: cpp;">
#pragma mark -

#pragma mark Parser delegates

- (void) parser:(NSXMLParser *)parser
didStartElement:(NSString *)elementName
   namespaceURI:(NSString *)namespaceURI
  qualifiedName:(NSString *)qualifiedName
	attributes:(NSDictionary *)attributeDict
{
	State = @&quot;&quot;;

	if ( [elementName isEqualToString:@&quot;Latitude&quot;] )
 		State = @&quot;1&quot;;

	if ( [elementName isEqualToString:@&quot;Longitude&quot;])
		State = @&quot;2&quot;;
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
	if ( [State isEqualToString:@&quot;1&quot;] ) Latitude = string;
	if ( [State isEqualToString:@&quot;2&quot;] ) Longitude = string;
}</pre>
<p>&nbsp;</p>
<p>Enjoy!</p>
<p></resultset></p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/xcode-using-mapkit-with-no-geocoding-available-out-of-the-box/">XCode : using MapKit with no geocoding available out of the box</a></p>
<div class="shr-publisher-580"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/xcode-using-mapkit-with-no-geocoding-available-out-of-the-box/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Objective-C: Base64 to NSString and NSString to Base64</title>
		<link>http://www.radupoenaru.com/objective-c-base64/</link>
		<comments>http://www.radupoenaru.com/objective-c-base64/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 16:17:00 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[CSCW Lab- iPhone]]></category>
		<category><![CDATA[Interface Buider]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Media Informatics]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[RWTH Aachen]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/objective-c-base64/</guid>
		<description><![CDATA[While working on the CSCW Lab project, I encountered a situation in which the XML-RPC call returned an image, of course encoded as Base64. And guess what &#8211; in its known style, Apple doesn&#8217;t provide Base64 encoding and decoding &#8211; quite lame, given the fact that this encoding is used everywhere in data transfer over&#8230;<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/objective-c-base64/">Objective-C: Base64 to NSString and NSString to Base64</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-base64%2F' data-shr_title='Objective-C%3A+Base64+to+NSString+and+NSString+to+Base64'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-base64%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-base64%2F' data-shr_title='Objective-C%3A+Base64+to+NSString+and+NSString+to+Base64'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-base64%2F' data-shr_title='Objective-C%3A+Base64+to+NSString+and+NSString+to+Base64'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode1.png"><img width="240" height="240" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode_thumb1.png" alt="xcode" title="xcode" style="border-width: 0px; margin: 10px; display: inline;" /></a></p>
<p>While working on the CSCW Lab project, I encountered a situation in which the XML-RPC call returned an image, of course encoded as Base64. And guess what &ndash; in its known style, Apple doesn&rsquo;t provide Base64 encoding and decoding &ndash; quite lame, given the fact that this encoding is used everywhere in data transfer over the internet &ndash; e-mail, browsers, web services &ndash; all of them use at some point this encoding to overcome the different local encodings on each one&rsquo;s machine.</p>
<p>Once identified this problem, I had to solve it somehow &ndash; but guess what? &ndash; over the free sources there aren&rsquo;t too many functions that provide this simple and basic encoding.</p>
<p>Finally, after few hours of searching, I finally found that Eric Czarny had a very successful implementation of this in its <a href="http://groups.google.com/group/cocoa-xmlrpc-framework?pli=1">Cocoa XML-RPC Framework</a> . After taking a quick look at its code, I end up using and importing into my project the</p>
<ul>
<li>NSStringAdditions.h. NSStringAdditions.m &ndash; providing the new category</li>
</ul>
<p>+ (NSString *)base64StringFromData: (NSData *)data length: (int)length;</p>
<ul>
<li>NSDataAdditions.h and NSDataAdditions providing the new category:</li>
</ul>
<p>+ (NSData *)base64DataFromString: (NSString *)string;</p>
<p>Being categories, they are automatically added to NSString and NSData automatically at runtime, thus their usage is straight forward :</p>
<pre class="brush: cpp;">
UIImageView *uiIV;
// currentElementValue holds the string representation of the image, encoded in Base64
NSData *nsD = [NSData base64DataFromString: [dataLayer currentElementValue]];

if ([nsD ){
    uiIV = [[UIImageView alloc] initWithImage:[UIImage imageWithData: nsD]];
}</pre>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/objective-c-base64/">Objective-C: Base64 to NSString and NSString to Base64</a></p>
<div class="shr-publisher-575"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/objective-c-base64/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processing NSDate into an ISO8601 string</title>
		<link>http://www.radupoenaru.com/processing-nsdate-into-an-iso8601-string/</link>
		<comments>http://www.radupoenaru.com/processing-nsdate-into-an-iso8601-string/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 15:45:00 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[CSCW Lab- iPhone]]></category>
		<category><![CDATA[Cocoa Touch]]></category>
		<category><![CDATA[Interface Buider]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Media Informatics]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[RWTH Aachen]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/processing-nsdate-into-an-iso8601-string/</guid>
		<description><![CDATA[&#160; During the CSCW Lab, where I had the experience of working on iPhone, I had to connect to a XML RPC server. Some of the parameters of the request had to be formatted as ISO8601 standard. After some reading, I end up using the following code, managing both the conversion of a NSDate to&#8230;<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/processing-nsdate-into-an-iso8601-string/">Processing NSDate into an ISO8601 string</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fprocessing-nsdate-into-an-iso8601-string%2F' data-shr_title='Processing+NSDate+into+an+ISO8601+string'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fprocessing-nsdate-into-an-iso8601-string%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fprocessing-nsdate-into-an-iso8601-string%2F' data-shr_title='Processing+NSDate+into+an+ISO8601+string'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fprocessing-nsdate-into-an-iso8601-string%2F' data-shr_title='Processing+NSDate+into+an+ISO8601+string'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode.png"><img width="240" height="240" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode_thumb.png" alt="xcode" title="xcode" style="border-width: 0px; margin: 10px; display: inline;" /></a></p>
<p>&nbsp;</p>
<p>During the CSCW Lab, where I had the experience of working on iPhone, I had to connect to a XML RPC server. Some of the parameters of the request had to be formatted as <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO8601 standard</a>. After some reading, I end up using the following code, managing both the conversion of a NSDate to NSString and a NSString to a NSDATE using the above format:</p>
<p>&nbsp;</p>
<p><strong><u>NSString &ndash;&gt; NSDate</u></strong></p>
<pre class="brush: cpp;">
-(NSString *) strFromISO8601:(NSDate *) date {
    static NSDateFormatter* sISO8601 = nil;

    if (!sISO8601) {
        sISO8601 = [[NSDateFormatter alloc] init];

        NSTimeZone *timeZone = [NSTimeZone localTimeZone];
        int offset = [timeZone secondsFromGMT];

        NSMutableString *strFormat = [NSMutableString stringWithString:@&quot;yyyyMMdd'T'HH:mm:ss&quot;];
        offset /= 60; //bring down to minutes
        if (offset == 0)
            [strFormat appendString:ISO_TIMEZONE_UTC_FORMAT];
        else
            [strFormat appendFormat:ISO_TIMEZONE_OFFSET_FORMAT, offset / 60, offset % 60];

        [sISO8601 setTimeStyle:NSDateFormatterFullStyle];
        [sISO8601 setDateFormat:strFormat];
    }
    return[sISO8601 stringFromDate:date];
} </pre>
<p><span id="more-571"></span></p>
<p><strong><u>NSDate &ndash;&gt; NSString^</u></strong></p>
<pre class="brush: cpp;">
-(NSDate *) dateFromISO8601:(NSString *) str {
    static NSDateFormatter* sISO8601 = nil;

    if (!sISO8601) {
        sISO8601 = [[NSDateFormatter alloc] init];
        [sISO8601 setTimeStyle:NSDateFormatterFullStyle];
        [sISO8601 setDateFormat:@&quot;yyyyMMdd'T'HH:mm:ss&quot;];
    }
    if ([str hasSuffix:@&quot;Z&quot;]) {
        str = [str substringToIndex:(str.length-1)];
    }

    NSDate *d = [sISO8601 dateFromString:str];
    return d;

}</pre>
<p>&nbsp;</p>
<p>Enjoy!</p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/processing-nsdate-into-an-iso8601-string/">Processing NSDate into an ISO8601 string</a></p>
<div class="shr-publisher-571"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/processing-nsdate-into-an-iso8601-string/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Objective-C: Use NSXMLParser</title>
		<link>http://www.radupoenaru.com/objective-c-use-nsxmlparser/</link>
		<comments>http://www.radupoenaru.com/objective-c-use-nsxmlparser/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 20:04:47 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[CSCW Lab- iPhone]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Media Informatics]]></category>
		<category><![CDATA[NSXMLParser]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/objective-c-use-nsxmlparser/</guid>
		<description><![CDATA[Almost any time you&#8217;ll need to pull some data from the web. Using Objective-C you have at your disposal a pretty good XML parser &#8211; the event-based version. What really means is that instead of building in-memory tree with the structure of the XML you&#8217;ll have some events raised when the parser encounters a special&#8230;<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/objective-c-use-nsxmlparser/">Objective-C: Use NSXMLParser</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-use-nsxmlparser%2F' data-shr_title='Objective-C%3A+Use+NSXMLParser'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-use-nsxmlparser%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-use-nsxmlparser%2F' data-shr_title='Objective-C%3A+Use+NSXMLParser'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-use-nsxmlparser%2F' data-shr_title='Objective-C%3A+Use+NSXMLParser'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode5.png"><img width="240" height="240" border="0" align="left" style="border: 0px none ; margin: 10px; display: inline;" title="xcode" alt="xcode" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode_thumb5.png" /></a> Almost any time you&#8217;ll need to pull some data from the web. Using Objective-C you have at your disposal a <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html" target="_blank">pretty good XML parser</a> &#8211; the event-based version. What really means is that instead of building in-memory tree with the structure of the XML you&#8217;ll have some events raised when the parser encounters a special token &#8211; the most usual ones are tag start, tag end and found comments. The parsing goes node by node and is not nesting-sensitive. As soon as the parser returns you a node, you don&rsquo;t know where in the structure you are currently anymore. As long as you have a clearly defined structure where each element is always present, you could do this using a counter. However, as soon as you have multiple nodes with no defined count, you have a problem.</p>
<p>The usage is simple and straight-forward. For simplicity, we assume that we have only have one level of children under the root node, but this can be easily extended to many levels.&nbsp; We&#8217;ll see some code and after that the detailed explanations:    </p>
<pre class="brush:objc">
- (void)parseJourneyData:(NSData *)data parseError:(NSError **)err {
// create and allocate the parser - it must be initiated with the XML data that we received or loaded
NSXMLParser *xmlParser= [[NSXMLParser alloc] initWithData:data];
  self.arrResult= [[NSMutableArray alloc] init];
  // Create the array for holding the resulted data
  [xmlParser setDelegate:self];
  // The parser calls will be redirected to methods in this class
  [xmlParser setShouldProcessNamespaces:NO];
  // We are not interested in namespaces
  [xmlParser setShouldReportNamespacePrefixes:NO];
  // neither in prefixes
  [xmlParser setShouldResolveExternalEntities:NO];
  // just data, no other stuff
  [xmlParserparse];
  // Parse that data.. here the parsing begins and the delegated methods will get called
  //the parsing process ended and we check for errors
  if (err &#038;&#038; [xmlParser parserError]) {
	*err = [xmlParser parserError];
  }
  [xmlParser release];
  //cleaning the remainders
  }
</pre>
<p><span id="more-554"></span></p>
<p>The next step is to implement the&nbsp; delegate methods. The easiest way to find them is to start the help system of XCode &#8211; while in IDE, keep the Alt key pressed until the cursor transforms into an cross and then double click on the element for which help is required, in our case NSXMLParser. In the window that appears, you&#8217;ll find easily the methods declarations as follows and you&#8217;ll notice that they are pretty descriptive by themselfs:    </p>
<pre class="brush:objc">
- (void)parser:(NSXMLParser *)parser
    idStartElement:(NSString *)elementName
    namespaceURI:(NSString *)namespaceURI
    qualifiedName:(NSString *)qName
    attributes:(NSDictionary *)attributeDict;
- (void)parser:(NSXMLParser *)parser
	foundCharacters:(NSString *)string;
- (void)parser:(NSXMLParser *)parser
	idEndElement:(NSString *)elementName
    namespaceURI:(NSString *)namespaceURI
    qualifiedName:(NSString *)qName;
</pre>
<p>Now let&#8217;s fill them with some code:    </p>
<pre class="brush:objc">
- (void)parser:(NSXMLParser *)parser
 didStartElement:(NSString *)elementName
 namespaceURI:(NSString *)namespaceURI
 qualifiedName:(NSString *)qName
 attributes:(NSDictionary *)attributeDict {
    if (qName) {
       elementName = qName;
    }
    // alloc the current property
    self.currentProperty = [NSMutableString string];
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string     {
    if (self.currentProperty) {
      [currentProperty appendString:string];
    }
}     

- (void)parser:(NSXMLParser *)parser
  didEndElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI
  qualifiedName:(NSString *)qName {
    if (qName) {
      elementName = qName;
    }
    [arrResult addObject:self.currentProperty];
    // We reset the currentProperty, for the next textnodes..
    self.currentProperty = nil;
}
</pre>
<p>That&#8217;s pretty much it. Happy coding!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/objective-c-use-nsxmlparser/">Objective-C: Use NSXMLParser</a></p>
<div class="shr-publisher-554"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/objective-c-use-nsxmlparser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C: allocation and deallocation</title>
		<link>http://www.radupoenaru.com/objective-c-allocation-and-deallocation/</link>
		<comments>http://www.radupoenaru.com/objective-c-allocation-and-deallocation/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 19:25:40 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[CSCW Lab- iPhone]]></category>
		<category><![CDATA[My work]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Media Informatics]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/objective-c-allocation-and-deallocation/</guid>
		<description><![CDATA[While reading the book by Mr. Kochan (1st ed): &#34;Programming in Objective C&#34; , I noticed that he uses the following code (you can see it at pages 342-344) to explain that the initWithString is preferable to stringWithString because the AddressCard class would own the name variable contents. Also, I don&#8217;t get any errors making&#8230;<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/objective-c-allocation-and-deallocation/">Objective-C: allocation and deallocation</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-allocation-and-deallocation%2F' data-shr_title='Objective-C%3A+allocation+and+deallocation'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-allocation-and-deallocation%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-allocation-and-deallocation%2F' data-shr_title='Objective-C%3A+allocation+and+deallocation'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-allocation-and-deallocation%2F' data-shr_title='Objective-C%3A+allocation+and+deallocation'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode4.png"><img width="240" height="240" border="0" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode_thumb4.png" alt="xcode" title="xcode" style="border: 0px none ; margin: 10px 0px; display: inline;" /></a> While reading the book by Mr. Kochan (1st ed): &quot;Programming in Objective C&quot; , I noticed that he uses the following code (you can see it at pages 342-344) to explain that the initWithString is preferable to stringWithString because the AddressCard class would own the name variable contents. Also, I don&#8217;t get any errors making repeated calls to the setName version with the stringWithString method.</p>
<p>&nbsp;&nbsp;</p>
<pre class="brush:objc;display:block">
//I didn't added here the header file which has the needed declarations
#import &quot;AddressCard.h&quot;
@implementation AddressCard;
-(NSString *) name{
return name;
}

//Recommended code:
-(void) setName: (NSString *) theName{
[name release]
name = [[NSString alloc] initWthString: theName];
}

//Incorrect code according to Kochan:
-(void) setName: (NSString *) theName{
[name release]
name = [NSString stringWthString: theName];
}
<span id="more-541"></span>
//I skipped the rest of class implementation
@end
</pre>
<p>The problem was that I didn&rsquo;t quite well understand why is better to use the stringWithString method since any local variable assigned that way would have it&#8217;s memory &quot;owned&quot; by NSString instead of the local class.</p>
<p>But the fact is that I misunderstood it. After more reading, the rules are quite crisp and easy to understand :</p>
<ul>
<li>all objects which are returned by an <code>alloc</code>, <code>copy</code>, <code>copyWithZone</code>, or <code>new</code> call have a retain count of 1.</li>
<li>any <code>retain</code> increases the receiving object&#8217;s retain count.</li>
<li>any <code>release</code> decreases the receiving object&#8217;s retain count.</li>
<li>the <code>autorelease</code> tells the current autorelease pool to send the receiving object the <code>release</code> message &ldquo;later&rdquo;.</li>
<li>As a general rule, any factory method that doesn&#8217;t have &ldquo;new&rdquo; or &ldquo;copy&rdquo; in the name (e.g., <code>stringWithString:</code>) returns an object that it has autoreleased on your behalf.</li>
</ul>
<p>In English words for newbies to Objective-C as I am:</p>
<ul>
<li>Any method whose name contains <code>copy</code>, <code>alloc</code>, <code>retain</code>, or <code>new</code> returns an object that you own.</li>
<li>Any method that doesn&#8217;t, returns an object that you don&#8217;t own.</li>
<li>To own an object, retain it.</li>
</ul>
<p>The incorrect part of the implementation of <code>setName:</code> that I showed before is the fact that it stores an autoreleased object in an instance variable, while I mean to own the object. Either I should retain it or, in this case, copy it.</p>
<p>The simpler case is to use <code>alloc</code> and <code>initWithString:</code>, as in the correct example; the other way would be <code>copy</code>.</p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/objective-c-allocation-and-deallocation/">Objective-C: allocation and deallocation</a></p>
<div class="shr-publisher-541"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/objective-c-allocation-and-deallocation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C: NSDictionary and NSMutableDictionary can&#8217;t keep the order of entries</title>
		<link>http://www.radupoenaru.com/objective-c-nsdictionary-and-nsmutabledictionary-cant-keep-the-order-of-entries/</link>
		<comments>http://www.radupoenaru.com/objective-c-nsdictionary-and-nsmutabledictionary-cant-keep-the-order-of-entries/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 18:52:02 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[CSCW Lab- iPhone]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Media Informatics]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/objective-c-nsdictionary-and-nsmutabledictionary-cant-keep-the-order-of-entries/</guid>
		<description><![CDATA[My latest task in CSCW Lab was to create the parser class for parsing some huge and multilevel XML. All nice and easy at first sight. Since the XML was the result of an RPC call, I got back some structures corresponding to NSDictionary and some arrays corresponding to NSArray in Apple's Objective-C.<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/objective-c-nsdictionary-and-nsmutabledictionary-cant-keep-the-order-of-entries/">Objective-C: NSDictionary and NSMutableDictionary can&#8217;t keep the order of entries</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-nsdictionary-and-nsmutabledictionary-cant-keep-the-order-of-entries%2F' data-shr_title='Objective-C%3A+NSDictionary+and+NSMutableDictionary+can%27t+keep+the+order+of+entries'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-nsdictionary-and-nsmutabledictionary-cant-keep-the-order-of-entries%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-nsdictionary-and-nsmutabledictionary-cant-keep-the-order-of-entries%2F' data-shr_title='Objective-C%3A+NSDictionary+and+NSMutableDictionary+can%27t+keep+the+order+of+entries'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-nsdictionary-and-nsmutabledictionary-cant-keep-the-order-of-entries%2F' data-shr_title='Objective-C%3A+NSDictionary+and+NSMutableDictionary+can%27t+keep+the+order+of+entries'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><img vspace="10" hspace="10" align="left" alt="XCode 3.0 - NSDictionary can't keep the order of its elements" src="http://www.radupoenaru.com/wp-content/uploads/2009/06/Xcode.jpg" />My latest task in CSCW Lab was to create the parser class for parsing some huge and multilevel XML. All nice and easy at first sight. Since the XML was the result of an RPC call, I got back some structures corresponding to <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/index.html">NSDictionary </a>and some arrays corresponding to <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/Reference/Reference.html">NSArray </a>in Apple&#8217;s Objective-C.</p>
<p>While iterating in the structure using <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/">NSXMLParser</a>, a event-based parser, I kept adding the pairs as name and values to the parent.The normal approach would be to add the name and NSNull for value first, then when retrieving the value&#8217;s content, search the last inserted entry ( the pair composed by name and value) and just fill the value with content. First I instantiate the strKey with the last key obtained from the array who contains all dictionary keys, then I set the value for the key already computed.The code that I used was :</p>
<pre class="brush:objc">
// get the last element in the dictionary and set it's value
NSString *strKey = [[(NSMutableDictionary *)parentObj allKeys] lastObject];
[(NSMutableDictionary *)parentObj setObject:theValue forKey:strKey];
</pre>
<p>But surprise! the last value is the same always (in my specific case the first added element). What the heck ? </p>
<p>Digging more deeply into this, seems that setObject:ForKey doesn&#8217;t ADD at the end of the dictionary, but more randomly insert the elements.</p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/objective-c-nsdictionary-and-nsmutabledictionary-cant-keep-the-order-of-entries/">Objective-C: NSDictionary and NSMutableDictionary can&#8217;t keep the order of entries</a></p>
<div class="shr-publisher-532"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/objective-c-nsdictionary-and-nsmutabledictionary-cant-keep-the-order-of-entries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C: UIAlert or asking for confirmation</title>
		<link>http://www.radupoenaru.com/objective-c-uialert-or-asking-for-confirmation/</link>
		<comments>http://www.radupoenaru.com/objective-c-uialert-or-asking-for-confirmation/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 06:58:42 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[CSCW Lab- iPhone]]></category>
		<category><![CDATA[Interface Buider]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Media Informatics]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[UIAlert]]></category>
		<category><![CDATA[User experience]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/objective-c-uialert-or-asking-for-confirmation/</guid>
		<description><![CDATA[While start XCoding, I faced a new challenge : how to create modal, single use confirmation dialogs? So after some digging in the internet, I found out that this can be actually done pretty simple and elegant. This will be very useful if you want to display some deletion confirmation or ask for user permission&#8230;<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/objective-c-uialert-or-asking-for-confirmation/">Objective-C: UIAlert or asking for confirmation</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-uialert-or-asking-for-confirmation%2F' data-shr_title='Objective-C%3A+UIAlert+or+asking+for+confirmation'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-uialert-or-asking-for-confirmation%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-uialert-or-asking-for-confirmation%2F' data-shr_title='Objective-C%3A+UIAlert+or+asking+for+confirmation'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fobjective-c-uialert-or-asking-for-confirmation%2F' data-shr_title='Objective-C%3A+UIAlert+or+asking+for+confirmation'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode6.png"><img width="240" height="240" border="0" align="left" style="border-width: 0px; margin: 10px; display: inline;" title="xcode" alt="xcode" src="http://www.radupoenaru.com/wp-content/uploads/2009/08/xcode_thumb6.png" /></a> While start XCoding, I faced a new challenge : how to create modal, single use confirmation dialogs? So after some digging in the internet, I found out that this can be actually done pretty simple and elegant. This will be very useful if you want to display some deletion confirmation or ask for user permission to use the camera or GPS sensor. All you have to do is just create a UIAlert and the IBAction hooked up to your &#8220;Nuclear launch&#8221; button, and then have <span style="color: rgb(255, 0, 0);"><em>its</em> </span>delegate decide whether to destroy the world or not.</p>
<p>In the header file you have to add this declaration of the action performed when the fatal button is clicked:</p>
<pre class="brush:objc">
- (IBAction) btnLaunchNuclearStrikeClicked:(id)sender
- (IBAction) deleteButtonClicked:(id)sender;

<span id="more-524"></span>
// And inside this action, create an alert with two buttons and show it:
- IBAction) btnLaunchNuclearStrikeClicked:(id)sender{
  // create a simple alert with an OK and cancel button
  UIAlertView *alert = [[UIAlertView alloc]
    initWithTitle:@"Do you really want to start the End of World?"
	message:nil
	delegate:self
	cancelButtonTitle:@"No, cancel Red Day"
	otherButtonTitles:@"Yes, initia", nil];
  [alert show];
  [alert release];
}
</pre>
<p>What&#8217;s important to notice is how the delegate is set to <em>self.</em> So this alert will be modal (indeed, is blocking the main thread &mdash; the user has to press a button to continue using the application). After the user presses a button, the alert will call the following method on the self object:</p>
<pre class="brush:objc">
- (void)alertView:(UIAlertView *)alertView
    clickedButtonAtIndex:(NSInteger)buttonIndex
</pre>
<p>Now we have to understand some conventions :the buttonIndex will be equal to 1 if the OK button was pressed, and nil otherwise, so we can handle the launch nuclear strike operation in here.</p>
<pre class="brush:objc">
- (void)alertView:(UIAlertView *)alertView
    clickedButtonAtIndex:(NSInteger)buttonIndex{
  if (buttonIndex == 1) {
    // Launch nuclear strike !
  } else {
	// be nice with the world, maybe initiate some Ecological action as a bonus
  }
}
</pre>
<p>That&#8217;s it, folks! A small step for you, big improvement in user experience &#8211; add confirmations to the more severe operations in your iPhone app.</p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/objective-c-uialert-or-asking-for-confirmation/">Objective-C: UIAlert or asking for confirmation</a></p>
<div class="shr-publisher-524"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/objective-c-uialert-or-asking-for-confirmation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->

