<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Matthias Wessendorf&#039;s Weblog</title>
	<atom:link href="http://matthiaswessendorf.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://matthiaswessendorf.wordpress.com</link>
	<description>A private tech blog on things I am interested in</description>
	<lastBuildDate>Fri, 03 May 2013 12:43:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='matthiaswessendorf.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Matthias Wessendorf&#039;s Weblog</title>
		<link>http://matthiaswessendorf.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://matthiaswessendorf.wordpress.com/osd.xml" title="Matthias Wessendorf&#039;s Weblog" />
	<atom:link rel='hub' href='http://matthiaswessendorf.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Attending UIKonf</title>
		<link>http://matthiaswessendorf.wordpress.com/2013/05/03/attending-uikonf/</link>
		<comments>http://matthiaswessendorf.wordpress.com/2013/05/03/attending-uikonf/#comments</comments>
		<pubDate>Fri, 03 May 2013 12:43:55 +0000</pubDate>
		<dc:creator>matthiaswessendorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://matthiaswessendorf.wordpress.com/?p=628</guid>
		<description><![CDATA[Yesterday I was in Berlin (always worth to go there) for attending the UIKonf: an iOS developers conference. The location (Heimathafen) was awesome! Pretty good atmosphere, and awesome coffee all day. Yay! The talk line-up was good as well. They &#8230; <a href="http://matthiaswessendorf.wordpress.com/2013/05/03/attending-uikonf/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=628&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Yesterday I was in Berlin (always worth to go there) for attending the <a href="http://uikonf.com">UIKonf</a>: an iOS developers conference. The location (Heimathafen) was awesome! Pretty good atmosphere, and awesome coffee all day. Yay!</p>
<p>The talk line-up was good as well. They had four rounds of sessions. All in one room, and each round had three sessions, that were scheduled to be 30 minutes: Perfect for getting quickly to the point!</p>
<p>The first session was pretty geeky. <a href="https://twitter.com/kluivers">Joris Kluivers</a> showed the Core Bluetooth Framework and did fancy things with a Mac, an iPhone and an actual lamp <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  The second talk (by <a href="https://twitter.com/NeoNacho">Boris Buegling</a>) was about the Objective-C Runtime. He showed common things like introspecting objects/methods or associative references. While talking he mention some of the Github Frameworks, like Mantle or libextobjc as good examples. Daniel Eggert gave a pretty basic overview on CoreData. Being a formal Apple employee he gave some hints regarding performance and optimizations. IMO the most interesting statement was given at the end: Do NOT use NSIncrementalStore.</p>
<p>Afterwards I asked and he explained that using remote/http for CoreData just feels wrong. Indeed, I have been there with <a href="https://github.com/AFNetworking/AFIncrementalStore/issues/150">AFIncrementalStore</a> too! Generally,&#8230; I am not that sure on CoreData&#8230;, and it looks like that most attendees were also not fans of CoreData <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="https://twitter.com/ceterum_censeo">Robb</a> gave a cool presentation about another Github Framework, called <a href="https://github.com/ReactiveCocoa/ReactiveCocoa">Reactive Cocoa</a>, which is an Objective-C framework for Functional Reactive Programming: It provides APIs for composing and transforming streams of values. It&#8217;s a nice framework, but not 100% sure we really need to integrate it into the AeroGear-iOS library&#8230;</p>
<p>Since I am very interested in testing, I really did enjoy <a href="https://twitter.com/tibr">Tim Brueckmann</a>&#8216;s talk on &#8220;Testing and iOS&#8221;. The talk was common sense, IMO and frameworks like Kiwi (for BDD) or OCUnit got mentioned. One thing I took away was <a href="https://github.com/AliSoftware/OHHTTPStubs">OHHTTPStubs</a>. Currently we have our own &#8220;NSURLProtocol&#8221; <a href="https://github.com/aerogear/aerogear-ios/blob/master/AeroGear-iOS/AeroGear-iOSTests/utils/AGMockURLProtocol.h">impl</a>, so that may go away <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Another talk, by <a href="https://twitter.com/floriankugler">Florian Kugler</a>, was on tooling/instruments. He showed how these tools can be used to find memory leaks and other issues with your code. A few talks were on Design and User Interaction. It&#8217;s not really my topic, but it was also not that bad <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  The last talk given by <a href="https://twitter.com/steipete">Peter Steinberg</a> was about tricks in your code, including some impressive reverse engineering.</p>
<p>The afterparty was at the Edelweiss bar/restaurant. With a few cold drinks the discussions continued all night long. Funny fact: a few mentioned their desire for something like <em>generics</em>, which I totally agree with!</p>
<p>For me it was a win, attending the conference. Various chats with folks that are longer doing iOS development was helpful, in kinda understanding that community. Also seeing we are using the right tools and libraries was good <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I think, it was also a bit interesting, that there were no talks on popular frameworks like AFNetworking or CocoaPods.</p>
<p><strong>Thanks to <a href="https://twitter.com/chriseidhof">Chris Eidhof</a> et al. for running such a great conference. I will come back <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthiaswessendorf.wordpress.com/628/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthiaswessendorf.wordpress.com/628/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=628&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthiaswessendorf.wordpress.com/2013/05/03/attending-uikonf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/92d27b816c7652e7bad5ecbfa76705a7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matze</media:title>
		</media:content>
	</item>
		<item>
		<title>Confess Vienna</title>
		<link>http://matthiaswessendorf.wordpress.com/2013/04/08/confess-vienna/</link>
		<comments>http://matthiaswessendorf.wordpress.com/2013/04/08/confess-vienna/#comments</comments>
		<pubDate>Mon, 08 Apr 2013 17:13:05 +0000</pubDate>
		<dc:creator>matthiaswessendorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://matthiaswessendorf.wordpress.com/?p=626</guid>
		<description><![CDATA[Last week I was attending the Confess Conference in Vienna. It was a pretty good conference with interesting attendees and talks. Most talks were in the &#8220;Enterprise Java&#8221; range (Java EE and Spring); added with content around Big-Data, and JavaScript/HTML(5). I &#8230; <a href="http://matthiaswessendorf.wordpress.com/2013/04/08/confess-vienna/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=626&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Last week I was attending the <a href="https://2013.con-fess.com/">Confess Conference in Vienna</a>. It was a pretty good conference with interesting attendees and talks. Most talks were in the &#8220;Enterprise Java&#8221; range (Java EE and Spring); added with content around Big-Data, and JavaScript/HTML(5).</p>
<p>I gave a presentation about using HTML/JavaScript bits with a RESTful JavaEE backend (meaning JAX-RS). It was an overview on different frameworks/libraries out there, demonstrated on-top of the <a href="https://github.com/aerogear/TODO/tree/master/server">AeroGear TODO backend</a> demo:</p>
<ul>
<li><span style="line-height:15px;">jQuery / jQuery Mobile</span></li>
<li>Backbone.js</li>
<li>AeroGear.js</li>
<li>Angular.js</li>
</ul>
<p>The client demo applications where executed in three different &#8220;containers&#8221;:</p>
<ul>
<li><span style="line-height:15px;">desktop browser</span></li>
<li>mobile browser (iOS simulator)</li>
<li>Apache Cordova application (iOS simulator)</li>
</ul>
<p>For the last demo, I showed our new AeroGear plugin for JBoss Forge (details <a href="https://gist.github.com/sebastienblanc/5222680">here</a>). It basically generates a JavaEE application, which uses Angular.js (for view templates and model declaration) and AeroGear.js (for the HTTP communication) as it&#8217;s Web technology.</p>
<p>Once the app is deployed it can be used in a (mobile) browser. The really cool part is that the HTML/JS bits from the generated app can be used as a native mobile app, by using <a href="https://github.com/apache/cordova-cli">Apache Cordova&#8217;s CLI</a> with just a few steps! (A blog entry will follow&#8230;)</p>
<p>Going was worth it and seeing old friends is always fun. Thanks to Irian for having me at Confess! <span style="font-style:inherit;line-height:15px;"><span style="font-style:inherit;line-height:1.625;">My slides are here: </span><em id="__mceDel" style="line-height:1.625;"><a href="http://people.apache.org/~matzew/Confess_2013" target="_blank">http://people.apache.org/~matzew/Confess_2013</a></em></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthiaswessendorf.wordpress.com/626/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthiaswessendorf.wordpress.com/626/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=626&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthiaswessendorf.wordpress.com/2013/04/08/confess-vienna/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/92d27b816c7652e7bad5ecbfa76705a7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matze</media:title>
		</media:content>
	</item>
		<item>
		<title>AeroGear iOS 1.0.0</title>
		<link>http://matthiaswessendorf.wordpress.com/2013/03/28/aerogear-ios-1-0-0/</link>
		<comments>http://matthiaswessendorf.wordpress.com/2013/03/28/aerogear-ios-1-0-0/#comments</comments>
		<pubDate>Thu, 28 Mar 2013 08:17:57 +0000</pubDate>
		<dc:creator>matthiaswessendorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://matthiaswessendorf.wordpress.com/?p=622</guid>
		<description><![CDATA[Today the AeroGear team is very happy to announce the 1.0.0 release of our iOS libraries: aerogear-ios aerogear-otp-ios The aerogear-ios project is a utility to communicate with remote server and storing data. The functionality of the library covers these areas: &#8230; <a href="http://matthiaswessendorf.wordpress.com/2013/03/28/aerogear-ios-1-0-0/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=622&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Today the AeroGear team is very happy to announce the 1.0.0 release of our iOS libraries:</p>
<ul>
<li><a href="https://github.com/aerogear/aerogear-ios/">aerogear-ios</a></li>
<li><a href="https://github.com/aerogear/aerogear-otp-ios">aerogear-otp-ios</a></li>
</ul>
<p>The aerogear-ios project is a utility to communicate with remote server and storing data. The functionality of the library covers these areas:</p>
<ul>
<li>HTTP REST abstraction + Paging</li>
<li>Authentication and User enrollment</li>
<li>Store and DataManager</li>
</ul>
<p>A <a href="https://github.com/aerogear/aerogear-todo-ios">TODO application</a> was built that shows the library, by communicating with our TODO application, on <a href="https://todoauth-aerogear.rhcloud.com/">OpenShift</a>.</p>
<p><em><strong>AeroGear meets Security</strong></em><em style="font-size:10px;letter-spacing:.1em;line-height:2.6em;text-transform:uppercase;"><strong><br />
</strong></em></p>
<p>The <a href="https://github.com/aerogear/aerogear-otp-ios">aerogear-otp-ios</a> project contains an iOS library for generating one time passwords according to <a href="http://tools.ietf.org/html/rfc6238">RFC 6238</a>. My colleague <a href="https://twitter.com/cvasilak/">Christos Vasilakis</a> describes the library <a href="http://cvasilak.blogspot.com/2012/12/aerogear-and-otp.html">here</a>. Feel free to give the little <a href="https://github.com/aerogear/aerogear-otp-ios-demo">demo</a> a try as well!</p>
<p><em><strong>More Documentation and Xcode Template</strong></em><em style="font-size:10px;letter-spacing:.1em;line-height:2.6em;text-transform:uppercase;"><strong><br />
</strong></em></p>
<p>Besides the libraries there are more goodies! The project offers a neat <a href="https://github.com/aerogear/aerogear-ios-xcode-template">template for Xcode</a>, to kickstart your development.<a href="http://staging.aerogear.org/docs/guides/GetStartedwithAeroGearandXcodeTemplate/">Check it out</a>! We also increased the documentation with a little <a href="http://staging.aerogear.org/docs/guides/GetStartedwithAeroGearandXcodeTemplate/">Cookbook</a></p>
<p>We hope you enjoy this release. We strongly encourage you to help us improving the project with feedback on the <a href="http://aerogear.org/community/">mailing list</a>, or via our <a href="https://issues.jboss.org/browse/AEROGEAR">JIRA instance</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthiaswessendorf.wordpress.com/622/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthiaswessendorf.wordpress.com/622/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=622&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthiaswessendorf.wordpress.com/2013/03/28/aerogear-ios-1-0-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/92d27b816c7652e7bad5ecbfa76705a7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matze</media:title>
		</media:content>
	</item>
		<item>
		<title>AeroGear 1.0.0 &#8211; Candidate Release 1</title>
		<link>http://matthiaswessendorf.wordpress.com/2013/03/04/aerogear-1-0-0-candidate-release-1/</link>
		<comments>http://matthiaswessendorf.wordpress.com/2013/03/04/aerogear-1-0-0-candidate-release-1/#comments</comments>
		<pubDate>Mon, 04 Mar 2013 15:28:07 +0000</pubDate>
		<dc:creator>matthiaswessendorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://matthiaswessendorf.wordpress.com/?p=612</guid>
		<description><![CDATA[Today we released our CR1! So, what&#8217;s new in iOS? With the new 1.0.0.CR1 release, we continued to focus on stabilisation! Besides adding more tests and maintainance, we have improved existing APIs and added a few new features. The AGStore &#8230; <a href="http://matthiaswessendorf.wordpress.com/2013/03/04/aerogear-1-0-0-candidate-release-1/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=612&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Today we released our CR1!</p>
<p><strong>So, what&#8217;s new in iOS?</strong></p>
<p><span style="font-style:inherit;line-height:1.625;">With the new 1.0.0.CR1 release, we continued to focus on stabilisation! Besides adding more tests and maintainance, we have improved existing APIs and added a few new features.</span></p>
<p>The AGStore protocol is now allowing you to apply filterings, by using the NSPredicate class (see <a href="https://github.com/aerogear/aerogear-ios/blob/master/AeroGear-iOS/AeroGear-iOS/datamanager/AGStore.h#L54">here</a>).</p>
<p>The AGPipe protocol has a <code>cancel</code> (see <a href="https://issues.jboss.org/browse/AEROGEAR-898">here</a>) to cancel running requests and its configuration is now aware of applying a <a href="https://issues.jboss.org/browse/AEROGEAR-824">timeout interval</a>.</p>
<p>Besides that, the OTP demo has been polished to run against a JSON-based backend.</p>
<p>The library can be found on CocoaPods! Enjoy!</p>
<p>As always, feedback is more than welcome!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthiaswessendorf.wordpress.com/612/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthiaswessendorf.wordpress.com/612/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=612&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthiaswessendorf.wordpress.com/2013/03/04/aerogear-1-0-0-candidate-release-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/92d27b816c7652e7bad5ecbfa76705a7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matze</media:title>
		</media:content>
	</item>
		<item>
		<title>CoreData &#8211; Data Mapping with AFIncrementalStore</title>
		<link>http://matthiaswessendorf.wordpress.com/2013/01/02/coredata-data-mapping-with-afincrementalstore/</link>
		<comments>http://matthiaswessendorf.wordpress.com/2013/01/02/coredata-data-mapping-with-afincrementalstore/#comments</comments>
		<pubDate>Wed, 02 Jan 2013 17:38:31 +0000</pubDate>
		<dc:creator>matthiaswessendorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://matthiaswessendorf.wordpress.com/?p=600</guid>
		<description><![CDATA[The AFIncrementalStore is a concrete implementation of the NSIncrementalStore API (see Chris&#8217; blog and NSHipster for more details), which allows you to access remote endpoints, like RESTful &#8220;Web Services&#8221;, by using the CoreData API. The project has three simple examples, &#8230; <a href="http://matthiaswessendorf.wordpress.com/2013/01/02/coredata-data-mapping-with-afincrementalstore/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=600&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The <a href="https://github.com/AFNetworking/AFIncrementalStore">AFIncrementalStore</a> is a concrete implementation of the <a href="https://developer.apple.com/library/ios/#documentation/CoreData/Reference/NSIncrementalStore_Class/Reference/NSIncrementalStore.html">NSIncrementalStore</a> API (see <a href="http://chris.eidhof.nl/post/17826914256/accessing-an-api-using-coredatas-nsincrementalstore">Chris&#8217; blog</a> and <a href="http://nshipster.com/nsincrementalstore/">NSHipster</a> for more details), which allows you to access remote endpoints, like RESTful &#8220;Web Services&#8221;, by using the CoreData API.</p>
<p>The project has three simple examples, including how to apply type mapping, in cases when you can&#8217;t use the JSON key in your class, like ID or description (as these are ObjC key words).</p>
<p>As shown in the examples, you need to override the <strong><em>attributesForRepresentation:ofEntity:fromResponse</em></strong> method, like:</p>
<pre class="brush: cpp; title: ; notranslate">
- (NSDictionary *)attributesForRepresentation:(NSDictionary *)representation
                                     ofEntity:(NSEntityDescription *)entity
                                 fromResponse:(NSHTTPURLResponse *)response
{
    NSMutableDictionary *mutablePropertyValues =
       [[super attributesForRepresentation:representation
                                  ofEntity:entity
                              fromResponse:response] mutableCopy];

    if ([entity.name isEqualToString:@&quot;Task&quot;]) {
        NSString *description =
          [representation valueForKey:@&quot;description&quot;];
        [mutablePropertyValues setValue:description forKey:@&quot;desc&quot;];
    }
    return mutablePropertyValues;
}
</pre>
<p>The above code basically says that on the Task entity (managed object) the <strong>desc</strong> property is used to store the result of the <strong>description</strong> key in the JSON response. However, the above code only works for reading&#8230;</p>
<p>In case you want to create or update a new entity, you need to override the <strong><em>representationOfAttributes:ofManagedObject</em></strong> method like below:</p>
<pre class="brush: cpp; title: ; notranslate">
- (NSDictionary *)representationOfAttributes:(NSDictionary *)attributes
                             ofManagedObject:(NSManagedObject *)managedObject {

    NSMutableDictionary *mutablePropertyValues =
        [[super representationOfAttributes:attributes
                           ofManagedObject:managedObject] mutableCopy];

    if ([managedObject.entity.name isEqualToString:@&quot;Task&quot;]) {
        NSString *description = [managedObject valueForKey:@&quot;desc&quot;];
        [mutablePropertyValues setValue:description forKey:@&quot;description&quot;];
        [mutablePropertyValues removeObjectForKey:@&quot;desc&quot;];
    }
    return mutablePropertyValues;
}
</pre>
<p>This code is basically the other way around&#8230; it reads the value from the managed object property (here <strong>desc</strong>), and stashes that on a dictionary, which is used by the underlying HTTP Client, to send the form data to the server. Inside of that dictionary, we are using the <strong>description</strong> key, that is required by our RESTful web service. To be safe&#8230; remove the <em>odd</em> <strong>desc</strong> field from the dictionary. Otherwise you <em>may</em> receive an error since the server does not like/understand the <strong>desc</strong> filed in the request&#8230;.</p>
<p>Once you managed this little oddnes, it&#8217;s straightforward. As mentioned <a href="http://matthiaswessendorf.wordpress.com/2012/11/19/objc-json/">before</a>, the ObjC type mapping to/from JSON is a little odd&#8230; This (of course) applies to CoreData and it&#8217;s managed objects as well.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthiaswessendorf.wordpress.com/600/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthiaswessendorf.wordpress.com/600/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=600&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthiaswessendorf.wordpress.com/2013/01/02/coredata-data-mapping-with-afincrementalstore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/92d27b816c7652e7bad5ecbfa76705a7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matze</media:title>
		</media:content>
	</item>
		<item>
		<title>AeroGear iOS lib &#8211; Milestone 2</title>
		<link>http://matthiaswessendorf.wordpress.com/2012/12/20/aerogear-ios-lib-milestone-2/</link>
		<comments>http://matthiaswessendorf.wordpress.com/2012/12/20/aerogear-ios-lib-milestone-2/#comments</comments>
		<pubDate>Thu, 20 Dec 2012 13:39:57 +0000</pubDate>
		<dc:creator>matthiaswessendorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://matthiaswessendorf.wordpress.com/?p=584</guid>
		<description><![CDATA[Today we, the AeroGear team at Red Hat, released the second version of our little iOS library, containing these new features: configuration objects query and search parameters OTP (One-Time Password) Model APIs and CoreData What&#8217;s new in iOS? Below the &#8230; <a href="http://matthiaswessendorf.wordpress.com/2012/12/20/aerogear-ios-lib-milestone-2/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=584&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Today we, the <a href="http://aerogear.org/">AeroGear</a> team at Red Hat, released the second version of our little iOS library, containing these new features:</p>
<ul>
<li>configuration objects</li>
<li>query and search parameters</li>
<li>OTP (<a href="http://en.wikipedia.org/wiki/One-time_password">One-Time Password</a>)</li>
<li>Model APIs and CoreData</li>
</ul>
<p><strong>What&#8217;s new in iOS?</strong></p>
<p>Below the features are described in a few sentences.</p>
<p><strong>configuration objects</strong></p>
<p>After the first milestone release, one key point was making the API a bit nicer. Instead of having lot&#8217;s of (long) methods to provide several <em>configuration options</em>, we decided to use a configuration object that&#8217;s passed in to a block:</p>
<pre class="brush: cpp; title: ; notranslate">
id projects = [pipeline pipe:^(id config) {
   [config name:@&quot;projects&quot;];
   [config type:@&quot;REST&quot;];
}];
</pre>
<p>As shown above, when creating a pipe, a <em>configuration object</em> is passed into the block function, where the App developer can specify the desired values for his pipe. This is also a nicer way, compared to using the builder &#8220;pattern&#8221;, which is more common in the Java world as described <a href="//matthiaswessendorf.wordpress.com/2012/11/12/objective-c-builder-pattern-vs-configuration-objects/">here</a>.</p>
<p><strong>query and search parameters</strong></p>
<p>Further, initial work has been done to support quering and paging of the data. Currently implemented in the Pipeline using the readWithFilter method, will allow you to specify your query (where clause) and paging (limit/offset) requirements, which will then be passed on your remote endpoints to process. Work is in progess, to support quering and paging on the local DataStore, exploiting some of the fine mechanisms that the iOS provides (e.g. <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSPredicate_Class/Reference/NSPredicate.html">NSPredicate</a>) and of course provide easier abstractions for our users to work with.</p>
<p>Quering and Paging is going to play an important role in the next couple of releases. Currently, there is an ongoing discussion in the <a href="http://aerogear-dev.1069024.n5.nabble.com/aerogear-dev-Query-Paging-Brainstorm-td764.html">mailing list</a>, so if there is correct time to get involved it is now! We would be more than happy to hear your ideas and suggestions.</p>
<p><strong>Model APIs and CoreData</strong></p>
<p>The current <a href="https://github.com/aerogear/aerogear-ios/blob/1.0.0.M2/API.md">AGPipe AP</a>I is using collections for persisting and receiving &#8220;objects&#8221; (e.g. <em>NSDictionary</em> is used to represent the object state in a key/value fashion):</p>
<pre class="brush: cpp; title: ; notranslate">
...
NSMutableDictionary* projectEntity = .....

// save the 'new' project:
[projects save:projectEntity success:myCallback failure:errorCallback];
</pre>
<p>The generic aspect of this means that your are pretty flexible in writing your own Model API layer. You could even use Github&#8217;s new Mantle Framework, like described <a href="//matthiaswessendorf.wordpress.com/2012/11/20/using-mantle-with-aerogear/">here</a>. We do have a demo app, using Mantle in our <a href="https://github.com/aerogear/aerogear-todo-ios/tree/mantle-AEROGEAR-635">repository</a>.</p>
<p><strong><em>CoreData outlook<br />
</em></strong>We started looking to support CoreData, but that will <strong><em>not</em></strong> happen over the above pipe API. The idea is to use the <a href="https://github.com/AFNetworking/AFIncrementalStore">AFIncrementalStore</a> to support the mapping of CoreData to HTTP, so that you can easily access our backend. The current plan is to have a subclass of <em>UIManagedDocument</em>, which uses a <em>AFIncrementalStore</em> instance for the HTTP/CoreData mapping. The benefit would be that iOS/CoreData developers can continue to use known and established APIs (e.g. <em>ManagedObjectContext</em>, <em>NSFetchRequest</em>, <em>FetchRequestController</em> etc). They would <em>just</em> use a different <em>UIManagedDocument</em> (sub)class.</p>
<p><strong>OTP</strong></p>
<p>My co-worker <a href="http://cvasilak.blogspot.com/">Christos Vasilakis</a> (author of the famous <a href="https://itunes.apple.com/us/app/jboss-admin/id523516060?ls=1&amp;mt=8">JBoss Admin iOS app</a>) wrote a detailed blog post how the AeroGear project is now support OTP on different platforms. <a href="http://cvasilak.blogspot.com/2012/12/aerogear-and-otp.html">Check it out</a>!</p>
<p><strong>We want feedback!</strong></p>
<p>As always, if there are concerns or missing features, let us know! Join the <a href="http://aerogear.org/community/">mailing list</a> for discussion, hangout on our #aerogear IRC channel or even file <a href="https://issues.jboss.org/browse/AEROGEAR">bugs</a>! We <em>are</em> happy to hear your thoughts and feedback!</p>
<p>Have fun!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthiaswessendorf.wordpress.com/584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthiaswessendorf.wordpress.com/584/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=584&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthiaswessendorf.wordpress.com/2012/12/20/aerogear-ios-lib-milestone-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/92d27b816c7652e7bad5ecbfa76705a7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matze</media:title>
		</media:content>
	</item>
		<item>
		<title>Writing mock tests for AFNetworking</title>
		<link>http://matthiaswessendorf.wordpress.com/2012/11/21/ocmock-and-afnetworking/</link>
		<comments>http://matthiaswessendorf.wordpress.com/2012/11/21/ocmock-and-afnetworking/#comments</comments>
		<pubDate>Wed, 21 Nov 2012 09:45:33 +0000</pubDate>
		<dc:creator>matthiaswessendorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://matthiaswessendorf.wordpress.com/?p=575</guid>
		<description><![CDATA[Mocking is not new and in the iOS space there is a nice library called OCMock. For HTTP communication the best library is AFNetworking. Both frameworks have some documentation on their project page, so I am not repeating basics here. &#8230; <a href="http://matthiaswessendorf.wordpress.com/2012/11/21/ocmock-and-afnetworking/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=575&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Mocking is not new and in the iOS space there is a nice library called <a href="http://ocmock.org/">OCMock</a>. For HTTP communication the best library is <a href="http://afnetworking.com/">AFNetworking</a>. Both frameworks have some documentation on their project page, so I am not repeating basics here. For OCMock I also liked <a href="http://alexvollmer.com/posts/2010/06/28/making-fun-of-things-with-ocmock/">this article</a> by Alex Vollmer.</p>
<p><em><strong>Mock the HTTP access</strong></em></p>
<p>Recently I had the requirement to mock the HTTP inside of &#8220;service classes&#8221;, that use the <em>AFHTTPClient</em> class for the network job. What I wanted to do is basically mock the (JSON) result of the <em>HTTP GET</em> request. With OCMock, it&#8217;s not that hard:</p>
<pre class="brush: objc; title: ; notranslate">
// create a mock of the AFHTTPClient:
id mockClient = [OCMockObject mockForClass:[AFHTTPClient class]];

// 1) build the expectations
//  * we expect that the &quot;getPath&quot; is invoked, once!
//  * here we don't care too much about the passed in arguments...
[[mockClient expect]
   getPath:[OCMArg isNotNil]
   parameters:[OCMArg isNil]
   success:[OCMArg isNotNil]
   failure:[OCMArg isNotNil]] ;

// 2) run the actual test:
    [mockClient getPath:@&quot;projects&quot;
       parameters:nil
       success:^(AFHTTPRequestOperation *operation, id responseObject) {
          NSLog(@&quot;SUCCESS&quot;);
       }
       failure:^(AFHTTPRequestOperation *operation, NSError *error) {
           NSLog(@&quot;FAIL&quot;);
    }];
</pre>
<p>Ok, that&#8217;s nice and the test passes &#8211; but none of the give blocks has been invoked.. In order to fake (-&gt;mock) a JSON response, we need to make sure that our &#8216;success&#8217; block is invoked. That&#8217;s quite simple with OCMock. The library offers an <strong>andDo</strong> method, were we are able to get access to all the agruments of the later invocation of the &#8220;getPath&#8221; method from the AFHTTPClient class:</p>
<pre class="brush: objc; title: ; notranslate">
// create a mock of the AFHTTPClient:
id mockClient = [OCMockObject mockForClass:[AFHTTPClient class]];

// 1) build the expectations
//  * we expect that the &quot;getPath&quot; is invoked, once!
//  * here we don't care too much about the passed in arguments...
//  * we use the andDo function to invoke the GIVEN (notNil) success block with our mocked JSON
[[[mockClient expect] andDo:^(NSInvocation *invocation) {

    // we define the sucess block:
    void (^successBlock)(AFHTTPRequestOperation *operation, id responseObject) = nil;

    // Using NSInvocation, we get access to the concrete block function
    // that has been passed in by the actual test
    // the arguments for the actual method start with 2 (see NSInvocation doc)
    [invocation getArgument:&amp;successBlock atIndex:4];

    // now we invoke the successBlock with some &quot;JSON&quot;...:
    successBlock(nil,
      [NSDictionary dictionaryWithObjectsAndKeys:@&quot;Bom Dia&quot;, @&quot;greetings&quot;, nil]
    );

}] getPath:[OCMArg any] parameters:nil success:[OCMArg any] failure:[OCMArg any]] ;

// 2) run the actual test
[mockClient getPath:@&quot;projects&quot; parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
  STAssertEqualObjects(
     @&quot;Bom Dia&quot;,
     [responseObject objectForKey:@&quot;greetings&quot;],
     @&quot;Some faked JSON&quot;
  );

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@&quot;FAIL&quot;);
}];
</pre>
<p>Now this test passes as well, and the responseObject contains the NSDictionary (-&gt; <em>JSON</em>) that we created inside of our expectations&#8230; Of course only the success block was invoked, but invoking the failure block is not that much harder.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthiaswessendorf.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthiaswessendorf.wordpress.com/575/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=575&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthiaswessendorf.wordpress.com/2012/11/21/ocmock-and-afnetworking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/92d27b816c7652e7bad5ecbfa76705a7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matze</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Mantle with AeroGear</title>
		<link>http://matthiaswessendorf.wordpress.com/2012/11/20/using-mantle-with-aerogear/</link>
		<comments>http://matthiaswessendorf.wordpress.com/2012/11/20/using-mantle-with-aerogear/#comments</comments>
		<pubDate>Tue, 20 Nov 2012 16:09:28 +0000</pubDate>
		<dc:creator>matthiaswessendorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://matthiaswessendorf.wordpress.com/?p=569</guid>
		<description><![CDATA[The last two days I looked at Mantle, and how it solves some issues, when working with JSON and a rich domain model. Now, how to use the Mantle framework with AeroGear&#8217;s iOS library? The Model &#8211; with Mantle Ok, &#8230; <a href="http://matthiaswessendorf.wordpress.com/2012/11/20/using-mantle-with-aerogear/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=569&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The last two days I looked at Mantle, and how it solves some issues, when working with <a href="http://matthiaswessendorf.wordpress.com/2012/11/19/objc-json/">JSON and a rich domain model</a>. Now, how to use the Mantle framework with AeroGear&#8217;s iOS library?</p>
<p><em><strong>The Model &#8211; with Mantle</strong></em></p>
<p>Ok, here is a quick snippet of a model:</p>
<pre class="brush: objc; title: ; notranslate">
@interface AGTask : MTLModel

@property(strong, nonatomic) NSNumber *recId;
@property(copy, nonatomic) NSString *title;
@property(copy, nonatomic) NSString *description;

@end
</pre>
<p>In the implementation we simply map the JSON <em>id</em> value to our <em>recId</em> field, since the &#8216;id&#8217; is a reserved keyword in Objc:</p>
<pre class="brush: objc; title: ; notranslate">
@implementation AGTask

@synthesize recId;
@synthesize title;
@synthesize description;

+ (NSDictionary *)externalRepresentationKeyPathsByPropertyKey {
    return [super.externalRepresentationKeyPathsByPropertyKey
       mtl_dictionaryByAddingEntriesFromDictionary:@{
           @&quot;recId&quot;: @&quot;id&quot;  // map the 'id' JSON string to our recId field!
     }];
}
@end
</pre>
<p><em><strong>Using AeroGear</strong></em></p>
<p>The AeroGear API is explained in <a href="https://github.com/aerogear/aerogear-ios/blob/master/API.md">here</a>, but below is a quick snippet, how to create a <em>AGPipe</em> instance to send the object to the server:</p>
<pre class="brush: objc; title: ; notranslate">
// NSURL object:
NSURL* serverURL = [NSURL URLWithString:@&quot;http://myserver.com/application/&quot;];

// create the 'todo' pipeline, which points to the baseURL of the REST application
AGPipeline* todo = [AGPipeline pipeline:serverURL];

// Add a REST pipe for the 'projects' endpoint
id&lt;AGPipe&gt; tasks = [pipeline pipe:^(id&lt;AGPipeConfig&gt; config) {
    [config name:@&quot;tasks&quot;];
    [config type:@&quot;REST&quot;];
}];
</pre>
<p>Now that we have the <em>tasks pipe</em>, we can create a <em>AGTask</em> object and send it to the server, using Mantle&#8217;s <em>externalRepresentation</em> function:</p>
<pre class="brush: objc; title: ; notranslate">
// create a model object:
__block AGTask* task = [[AGTask alloc] init];
tasks.title = @&quot;Create a screencast&quot;;
tasks.description = @&quot;Show how the things work...&quot;;

// store the ObjC object on the server and replace it with the returned object
[tasks save:[task externalRepresentation] success:^(id responseObject) {
    // Replace the object with the response:
    task = [AGTask modelWithExternalRepresentation:responseObject];
} failure:^(NSError *error) {
    // when an error occurs... at least log it to the console..
    NSLog(@&quot;SAVE: An error occured! \n%@&quot;, error);
}];
</pre>
<p>When the server has created the object, the returned (JSON) object contains a value for the &#8220;id&#8221; field, specified by the server. Inside of the success block, we update the task object with its latest representation, using another utility from Mantle, the <em>modelWithExternalRepresentation</em> class method.</p>
<p><em><strong>Outlook</strong></em></p>
<p>Right now the AeroGear library does not (yet?) internally use the Mantle framework, but the TODO demo app is using Mantle on a branch &#8211; for evaluation an inspiration!</p>
<p>Enjoy!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthiaswessendorf.wordpress.com/569/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthiaswessendorf.wordpress.com/569/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=569&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthiaswessendorf.wordpress.com/2012/11/20/using-mantle-with-aerogear/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/92d27b816c7652e7bad5ecbfa76705a7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matze</media:title>
		</media:content>
	</item>
		<item>
		<title>Objective-C: Working with JSON and mapping it a rich domain model</title>
		<link>http://matthiaswessendorf.wordpress.com/2012/11/19/objc-json/</link>
		<comments>http://matthiaswessendorf.wordpress.com/2012/11/19/objc-json/#comments</comments>
		<pubDate>Mon, 19 Nov 2012 10:15:50 +0000</pubDate>
		<dc:creator>matthiaswessendorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://matthiaswessendorf.wordpress.com/?p=549</guid>
		<description><![CDATA[Transforming Objects to JSON and building up an object graph from a JSON response is pretty standard. But how is it done with Objective-C? Imagine a very simple class Task: and let&#8217;s create an instance for the class: Cool! Now &#8230; <a href="http://matthiaswessendorf.wordpress.com/2012/11/19/objc-json/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=549&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Transforming Objects to JSON and building up an object graph from a JSON response is pretty standard. But how is it done with Objective-C? Imagine a <em>very</em> simple class Task:</p>
<pre class="brush: objc; title: ; notranslate">
@interface Task : NSObject

@property (nonatomic, copy) NSString* title;
@property (nonatomic, copy) NSString* desc;

@end
</pre>
<p>and let&#8217;s create an instance for the class:</p>
<pre class="brush: objc; title: ; notranslate">
Task* task1 = [[Task alloc] init];
task1.desc = @&quot;some description...&quot;;
task1.title= @&quot;My Title&quot;;
</pre>
<p>Cool! Now imagine you want the following JSON string:</p>
<pre class="brush: jscript; title: ; notranslate">
{
   &quot;title&quot; : &quot;My Title&quot;,
   &quot;desc&quot; : &quot;some description...&quot;
}
</pre>
<p>Ok that should be easy, especially since there is JSON support for iOS and also built-in to the iOS 5 SDK:</p>
<pre class="brush: objc; title: ; notranslate">
NSData* encodedData = [NSJSONSerialization dataWithJSONObject:task1 options:NSJSONWritingPrettyPrinted error:nil];
NSString* jsonString = [[NSString alloc] initWithData:encodedData encoding:NSUTF8StringEncoding];
</pre>
<p>Ok, this does NOT work &#8211; the <em>dataWithJSONObject</em> call explodes, saying <em>Invalid top-level type in JSON write</em>&#8230;</p>
<p>Trying a different JSON library does <strong>NOT</strong> fix it:</p>
<pre class="brush: objc; title: ; notranslate">
SBJsonWriter* writer = [[SBJsonWriter alloc] init];
NSString* str = [writer stringWithObject:task1];
</pre>
<p>There is no JSON string afterwards &#8211; the value is <em>nil</em> &#8230; That&#8217;s sad!</p>
<p><em><strong>JSON: How does it work</strong></em></p>
<p>Well, the above (JSON) libraries work on Foundation classes like <em>NSDictionary</em>. If you are able to return your object in a map form, these libs work just fine:</p>
<pre class="brush: objc; title: ; notranslate">
// a map that represents the above introduced task object...:
NSDictionary* task1 = [NSDictionary
   dictionaryWithObjectsAndKeys:@&quot;some description...&quot;, @&quot;desc&quot;, @&quot;My title&quot;, @&quot;title&quot;, nil];

NSData* encodedData = [NSJSONSerialization dataWithJSONObject:task1 options:NSJSONWritingPrettyPrinted error:nil];
NSString* jsonString [[NSString alloc] initWithData:encodedData encoding:NSUTF8StringEncoding];
</pre>
<p>Since we use the <em>pretty write option</em> the JSON looks like:</p>
<pre class="brush: jscript; title: ; notranslate">
{
  &quot;title&quot; : &quot;My title&quot;,
  &quot;desc&quot; : &quot;some description...&quot;
}
</pre>
<p>So yeah, we really need maps that are representing the object graph&#8230; Nice&#8230;</p>
<p><em><strong>Manual maps</strong></em></p>
<p>Having the requirement to manually implement a <em>get object as dictionary</em> and one <em>create from dictionary</em> function is a bit odd. However it is a pattern, which is used sometimes&#8230;  Something more magic/automatic would be nice, other have figured out that too&#8230;</p>
<p>There is a framework called <a href="https://github.com/jagill/JAGPropertyConverter">JAGPropertyConverter</a> that helps to <em>transform</em> object graphs into a <em>NSDictionary</em> that can be used with various JSON libraries. Now let&#8217;s make the object graph a little bit more complex&#8230; We add an <em>Employee</em> that can have n tasks&#8230;</p>
<pre class="brush: objc; title: ; notranslate">
@interface Employee : NSObject

@property (nonatomic, copy) NSString* name;
@property (nonatomic, copy) NSArray* tasks;
@end

...
...
Employee* employee = [[Employee alloc] init];
employee.name = @&quot;Mr. X&quot;;
employee.tasks = [NSArray arrayWithObjects:task1, task2, nil];
</pre>
<p>Now using the <em>JAGPropertyConverter</em>, we can easily transform the graph:</p>
<pre class="brush: objc; title: ; notranslate">
...
JAGPropertyConverter *converter = [[JAGPropertyConverter alloc] initWithOutputType:kJAGJSONOutput];
converter.classesToConvert = [NSSet setWithObjects:[Task class], [Employee class], nil];
NSDictionary *jsonDictionary = [converter convertToDictionary:employee];

...
SBJsonWriter* writer = [[SBJsonWriter alloc] init];
NSString* str = [writer stringWithObject:jsonDictionary];
</pre>
<p>The little <em>downside</em> is that I have to provide some information about my custom types (see <em>classesToConvert</em>)&#8230;</p>
<p><em><strong>Parsing JSON</strong></em></p>
<p>Writing out JSON is one thing &#8211; parsing the other. To make a long story short &#8211; similar issues are present when trying to transform a JSON string to a rich object model&#8230; The JSON parser libraries expect an array (<em>NSArray</em>) or a map (<em>NSDictionary</em>). So we need something that is able to transform the NSDictionary into a rich object graph&#8230;</p>
<p>For that I have tested the <a href="https://github.com/dchohfi/KeyValueObjectMapping">KeyValueObjectMapping</a> framework and also used the already discussed JAGPropertyConverter. Both function similar: With a little information about the used custom types, they are able to create an object graph out of the JSON data structures (<em>NSArray, <em>NSDictionary</em></em>).</p>
<p><strong><em>Github&#8217;s Mantle</em></strong></p>
<p>An other interesting option could be Github&#8217;s <a href="https://github.com/github/mantle">Mantle</a>. As stated on their project side, Mantle makes it easy to write a simple model layer for your Cocoa or Cocoa Touch application. It also adresses the JSON issue, as it offers an automatic/magic <em>externalRepresentation </em>function that returns a <em>NSDictionary</em> of the object (its state). However, your classes now needs to inherit from the <em>MTLModel</em> class:</p>
<pre class="brush: objc; title: ; notranslate">
@interface MantleTask : MTLModel

@property (nonatomic, copy) NSString* title;
@property (nonatomic, copy) NSString* desc;

@end
</pre>
<p>Getting the map/<em>NSDictonary</em> of one class is simple and generating the JSON is easy too:</p>
<pre class="brush: objc; title: ; notranslate">
MantleTask* task = [[MantleTask alloc] init];
task.title = @&quot;Some task&quot;;
task.desc = @&quot;lot's of workz&quot;;

NSData* encodedData = [NSJSONSerialization
    dataWithJSONObject:[task externalRepresentation]
    options:NSJSONWritingPrettyPrinted error:nil];

NSString* jsonString = [[NSString alloc] initWithData:encodedData encoding:NSUTF8StringEncoding];

</pre>
<p>The <em>pretty</em> JSON output looks like:</p>
<pre class="brush: jscript; title: ; notranslate">
{
  &quot;title&quot; : &quot;Some task&quot;,
  &quot;desc&quot; : &quot;lot's of workz&quot;
}
</pre>
<p>The Mantle framework also supports <em>nested</em> classes, but you have to also include some type-mapping information as well:</p>
<pre class="brush: objc; title: ; notranslate">
@implementation MantleEmployee
+ (NSValueTransformer *)tasksTransformer {
    return [NSValueTransformer
       mtl_externalRepresentationArrayTransformerWithModelClass:MantleTask.class];
}
@end
</pre>
<p>This class function knows about it&#8217;s subtypes&#8230; So again some information on the actual type system is needed.</p>
<p><em><strong>Summary</strong></em></p>
<p>Generally the Mantle Framework provides a (somewhat) clean solution for:</p>
<ul>
<li>generating maps (-&gt;JSON) out of an object graph</li>
<li>generating object graphs from maps (-&gt;JSON)</li>
</ul>
<p>Of course, Mantle also supports the case where the external representation (e.g. JSON) changes &#8211; you simple implement some mapping function, as shown on their project side.</p>
<p>So far Mantle looks like a great library when transforming objects to an external representation. I also appreciate the dynamic/magic support for creating an object from a map:</p>
<pre class="brush: objc; title: ; notranslate">
NSData* data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary* parsedObject = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];

MantleEmployee* parsedEmp = [[MantleEmployee alloc] initWithExternalRepresentation:parsedObject];
</pre>
<p>Similar to the above shown &#8220;externalRepresentation&#8221; function, which creates a NSDictionary of my object graph!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthiaswessendorf.wordpress.com/549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthiaswessendorf.wordpress.com/549/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=549&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthiaswessendorf.wordpress.com/2012/11/19/objc-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/92d27b816c7652e7bad5ecbfa76705a7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matze</media:title>
		</media:content>
	</item>
		<item>
		<title>AeroGear developer release</title>
		<link>http://matthiaswessendorf.wordpress.com/2012/11/14/aerogear-developer-release/</link>
		<comments>http://matthiaswessendorf.wordpress.com/2012/11/14/aerogear-developer-release/#comments</comments>
		<pubDate>Wed, 14 Nov 2012 14:13:08 +0000</pubDate>
		<dc:creator>matthiaswessendorf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://matthiaswessendorf.wordpress.com/?p=545</guid>
		<description><![CDATA[Yesterday we released a new version of the AeroGear library! Highlights are a more fluent API to create pipes,stores and authModules. Another milestone was the usage of using the previously discussed configuration objects! Get it from the CocoaPods repo! New way &#8230; <a href="http://matthiaswessendorf.wordpress.com/2012/11/14/aerogear-developer-release/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=545&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Yesterday we released a new version of the AeroGear library! Highlights are a more fluent API to create pipes,stores and authModules. Another milestone was the usage of using the previously discussed configuration objects!</p>
<p>Get it from the <a href="http://cocoapods.org/?q=AeroGear">CocoaPods repo</a>!</p>
<p><strong>New way to create a <em>AGPipe</em>:</strong></p>
<pre class="brush: objc; title: ; notranslate">
// NSURL object:
NSURL* serverURL = [NSURL URLWithString:@&quot;http://todo-aerogear.rhcloud.com/todo-server/&quot;];

// create the 'todo' pipeline, which points to the baseURL of the REST application
AGPipeline* todo = [AGPipeline pipeline:serverURL];

// Add a REST pipe for the 'projects' endpoint
id&lt;AGPipe&gt; projects = [pipeline pipe:^(id&lt;AGPipeConfig&gt; config) {
    [config name:@&quot;projects&quot;];
    [config type:@&quot;REST&quot;];
}];
</pre>
<p><strong>New way to create a <em>AGStore</em>:</strong></p>
<pre class="brush: objc; title: ; notranslate">
// create the datamanager
AGDataManager* dm = [AGDataManager manager];
// add a new (default) store object:
id&lt;AGStore&gt; myStore = [dm store:^(id&lt;AGStoreConfig&gt; config) {
    [config name:@&quot;tasks&quot;];
    [config TYPE:@&quot;MEMORY&quot;];
}];
</pre>
<p><strong>New way to create a <em>AGAuthenticationModule</em>:</strong></p>
<pre class="brush: objc; title: ; notranslate">
// create an authenticator object
AGAuthenticator* authenticator = [AGAuthenticator authenticator];

// add a new auth module and the required 'base url':
NSURL* baseURL = [NSURL URLWithString:@&quot;https://todoauth-aerogear.rhcloud.com/todo-server/&quot;];
id&lt;AGAuthenticationModule&gt; myMod = [authenticator auth:^(id&lt;AGAuthConfig&gt; config) {
    [config name:@&quot;authMod&quot;];
    [config baseURL:baseURL];
}];
</pre>
<p>As always, feedback and <a href="http://issues.jboss.org/browse/AEROGEAR">JIRAs</a> are welcome!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthiaswessendorf.wordpress.com/545/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthiaswessendorf.wordpress.com/545/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthiaswessendorf.wordpress.com&#038;blog=1129660&#038;post=545&#038;subd=matthiaswessendorf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthiaswessendorf.wordpress.com/2012/11/14/aerogear-developer-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/92d27b816c7652e7bad5ecbfa76705a7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matze</media:title>
		</media:content>
	</item>
	</channel>
</rss>
