<?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>Arash Payan &#124; Blog &#187; objective-c</title>
	<atom:link href="http://arashpayan.com/blog/index.php/tag/objective-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://arashpayan.com/blog</link>
	<description>(Place witty tagline here)</description>
	<lastBuildDate>Sun, 23 May 2010 22:28:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Presenting, Appirater</title>
		<link>http://arashpayan.com/blog/index.php/2009/09/07/presenting-appirater/</link>
		<comments>http://arashpayan.com/blog/index.php/2009/09/07/presenting-appirater/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 00:16:00 +0000</pubDate>
		<dc:creator>Arash</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[appirater]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://arashpayan.com/blog/?p=172</guid>
		<description><![CDATA[Like most developers, I&#8217;m not thrilled with the way the App Store presents my apps. There are several problems, but in particular, I really don&#8217;t like the user review system. It&#8217;s biased towards bad reviews, and that ends up hurting sales (there are odd exceptions to this). The only time a user is reminded or [...]]]></description>
			<content:encoded><![CDATA[<p>Like most developers, I&#8217;m not thrilled with the way the App Store presents my apps. There are several problems, but in particular, I really don&#8217;t like the user review system. It&#8217;s biased towards bad reviews, and that ends up hurting sales (there are odd exceptions to this). The only time a user is reminded or asked to rate an app is when you delete it, and you probably don&#8217;t care for the app if you&#8217;re deleting it. In comparison to the unhappy user, the satisfied user rarely takes the time to review your app. Which leaves you with crummy reviews from uninformed users hurting sales of your app.</p>
<p>If Apple would allow developers to respond to reviews, or more easily challenge the validity of a review, this would be no big deal. But I don&#8217;t have any hopes of Apple wising up and fixing anything, so I&#8217;m left trying to get more positive reviews of my apps to drown out the negatives ones.</p>
<p><strong>Appirater</strong><br />
The goal of Appirater is to encourage your satisfied user&#8217;s to rate your app. To use it, place the <a href="http://github.com/arashpayan/appirater/">Appirater code</a> into your project, and add the following code in your app&#8217;s delegate class.</p>
<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#236e25;">// import the Appirater class<br />
</span><span style="color:#683821;">#import &quot;Appirater.h&quot;<br />
</span><br />
<span style="color:#881350;">@implementation</span> MyAppDelegate</p>
<p>- (<span style="color:#881350;">BOOL</span>)<span style="color:#6c0540;">application:</span>(<span style="color:#400080;">UIApplication</span> *)application <span style="color:#6c0540;">didFinishLaunchingWithOptions:</span>(<span style="color:#400080;">NSDictionary</span> *)launchOptions {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;">// all your app&#8217;s startup code<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;">// &#8230;<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;">// call the Appirater class<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;[Appirater <span style="color:#6c0540;">appLaunched</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">return</span> <span style="color:#881350;">YES</span>;<br />
}</p>
<p><span style="color:#881350;">@end</span></div>
<p><br/><br />
Finally, open up <code>Appirater.h</code> and change the <code>APPIRATER_APP_ID</code> to your apps software id. You can also change the other <code>#define</code>s, for a more customized reminder message and buttons, but the default should suffice for most apps.</p>
<p>Now every time the user launches your app, Appirater will see if they&#8217;ve used the app for 30 days and launched it at least 15 times. If they have, they&#8217;ll be asked to rate the app, and then be taken to your app&#8217;s review page in the App Store. If you release a new version of your app, Appirater will again wait until the new version has been used 15 times for 30 days and then prompt the user again for another review. Optionally, you can adjust the days to wait and the launch number by changing <code>DAYS_UNTIL_PROMPT</code> and <code>LAUNCHES_UNTIL_PROMPT</code> in <code>Appirater.h</code>.</p>
<p><img src="http://arashpayan.com/blog/wp-content/uploads/2009/09/AppiraterScreenshot.png" alt="Appirater as used in Prayer Book app" title="Appirater as used in Prayer Book app" width="320" height="480" class="aligncenter size-full wp-image-188" /></p>
<p>Code: <a href="http://github.com/arashpayan/appirater/">http://github.com/arashpayan/appirater/</a></p>
<p>BTW, if you like Appirater, please consider checking out my game, <a href="http://itunes.com/app/Jabeh">Jabeh</a> or the <a href="http://itunes.com/app/JabehLite">lite version</a> of it.</p>
]]></content:encoded>
			<wfw:commentRss>http://arashpayan.com/blog/index.php/2009/09/07/presenting-appirater/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>APXML: NSXMLDocument &#8217;substitute&#8217; for iPhone/iPod Touch</title>
		<link>http://arashpayan.com/blog/index.php/2009/01/14/apxml-nsxmldocument-substitute-for-iphoneipod-touch/</link>
		<comments>http://arashpayan.com/blog/index.php/2009/01/14/apxml-nsxmldocument-substitute-for-iphoneipod-touch/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 05:04:45 +0000</pubDate>
		<dc:creator>Arash</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[apxml]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://arashpayan.com/blog/?p=46</guid>
		<description><![CDATA[After spending some time working on Jabeh, my latest creation for iPhone/iPod Touch, I&#8217;m taking some time to dump a little learned knowledge into my blog.
In my first app, my XML needs weren&#8217;t that great, so putting up with the lack of NSXMLDocument in the iPhone SDK was not a big deal. However, in Jabeh [...]]]></description>
			<content:encoded><![CDATA[<p>After spending some time working on <a href="http://jabeh.org">Jabeh</a>, my latest creation for iPhone/iPod Touch, I&#8217;m taking some time to dump a little learned knowledge into my blog.</p>
<p>In my first app, my XML needs weren&#8217;t that great, so putting up with the lack of <code>NSXMLDocument</code> in the iPhone SDK was not a big deal. However, in <a href="http://jabeh.org">Jabeh</a> I was changing the XML format so often and using so much of it for my network communication creating delegates for <code>NSXMLParser</code> quickly became a huge time sink. After a little hacking, I came up with APXML to solve my DOM problem. It&#8217;s not a perfect implementation of the <a href="http://www.w3.org/TR/REC-xml/">W3C XML 1.0 standard</a>, but it&#8217;s close enough for a lot of usage. One particular shortcoming is its lack of support for namespaces but maybe somebody else can add that support. If you just want to jump in and start using it (LGPL license), you can get the code from github:</p>
<p><a href="http://github.com/arashpayan/apxml/">http://github.com/arashpayan/apxml/</a></p>
<p>Most of my XML manipulation experience has been with various Java libraries (<a href="http://java.sun.com/javase/6/docs/api/org/w3c/dom/package-summary.html">org.w3c.dom interface</a>, <a href="http://jdom.org/">JDOM</a> and <a href="http://xom.nu/">XOM</a>), and the only one that I enjoyed using was XOM, because of its simplicity and licensing. Almost all of my design decisions were based on how XOM does things.</p>
<p>Let&#8217;s say we want to represent the following XML document in memory using APXML:</p>
<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#881280;">&lt;books&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;book </span><span style="color:#994500;">id</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;1&quot;</span><span style="color:#881280;"> </span><span style="color:#994500;">author</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;Michael Pollan&quot;</span><span style="color:#881280;">&gt;</span>The Omnivore&#8217;s Dilemma<span style="color:#881280;">&lt;/book&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881280;">&lt;book </span><span style="color:#994500;">id</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;2&quot;</span><span style="color:#881280;"> </span><span style="color:#994500;">author</span><span style="color:#881280;">=</span><span style="color:#1a1aa6;">&quot;Foley, van Dam, Feiner, Hughes&quot;</span><span style="color:#881280;">&gt;</span>Computer Graphics: Principles and Practices<span style="color:#881280;">&lt;/book&gt;</span><br />
<span style="color:#881280;">&lt;/books&gt;</span></div>
<p>In code, we do the following:</p>
<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#683821;">#import &quot;APXML.h&quot;<br />
</span><br />
<span style="color:#881350;">@implementation</span> AppDelegate</p>
<p>- (<span style="color:#881350;">void</span>)<span style="color:#6c0540;">applicationDidFinishLaunching:</span>(UIApplication *)application {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;">// create the document with it&#8217;s root element<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;APDocument *doc = [[APDocument <span style="color:#ff0000;">alloc</span>] <span style="color:#6c0540;">initWithRootElement:</span>[APElement <span style="color:#6c0540;">elementWithName:</span><span style="color:#760f15;">@&quot;books&quot;</span>]];<br />
&nbsp;&nbsp;&nbsp;&nbsp;APElement *rootElement = [doc <span style="color:#6c0540;">rootElement</span>]; <span style="color:#236e25;">// retrieves same element we created the line above<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;">// create the first book entry (The Omnivore&#8217;s Dilemma)<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;APElement *book1 = [APElement <span style="color:#6c0540;">elementWithName:</span><span style="color:#760f15;">@&quot;book&quot;</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[book1 <span style="color:#6c0540;">addAttributeNamed:</span><span style="color:#760f15;">@&quot;id&quot;</span> <span style="color:#6c0540;">withValue:</span><span style="color:#760f15;">@&quot;1&quot;</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[book1 <span style="color:#6c0540;">addAttributeNamed:</span><span style="color:#760f15;">@&quot;author&quot;</span> <span style="color:#6c0540;">withValue:</span><span style="color:#760f15;">@&quot;Michael Pollan&quot;</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[book1 <span style="color:#6c0540;">appendValue:</span><span style="color:#760f15;">@&quot;The Omnivore's Dilemma&quot;</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[rootElement <span style="color:#6c0540;">addChild:</span>book1];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;">// create the second book entry (Computer Graphics)<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;APElement *book2 = [APElement <span style="color:#6c0540;">elementWithName:</span><span style="color:#760f15;">@&quot;book&quot;</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[book2 <span style="color:#6c0540;">addAttributeNamed:</span><span style="color:#760f15;">@&quot;id&quot;</span> <span style="color:#6c0540;">withValue:</span><span style="color:#760f15;">@&quot;2&quot;</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[book2 <span style="color:#6c0540;">addAttributeNamed:</span><span style="color:#760f15;">@&quot;author&quot;</span> <span style="color:#6c0540;">withValue:</span><span style="color:#760f15;">@&quot;Foley, van Dam, Feiner, Hughes&quot;</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[rootElement <span style="color:#6c0540;">addChild:</span>book2];<br />
}</p>
<p><span style="color:#881350;">@end</span></div>
<p>And if we want to convert the document to an <code>NSString*</code>, we use one of the two methods in <code>APDocument</code>:</p>
<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; ">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;">// converts the xml to a compact string with no newlines or tabs (good for production)<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSString</span> *xml = [doc <span style="color:#6c0540;">xml</span>];</div>
<p>or</p>
<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; ">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;">// converts the xml to an easy to read string with newlines and tabs (good for debugging)<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSString</span> *prettyXML = [doc <span style="color:#6c0540;">prettyXML</span>];</div>
<p>Often times when I&#8217;m working with XML, I like to see what the current element contains, so for added convenience, you can obtain an XML string containing the element you&#8217;re working with, its attributes and all its children directly from the <code>APElement</code> by calling one of two methods:</p>
<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; ">- (<span style="color:#400080;">NSString</span>*)<span style="color:#6c0540;">prettyXML:</span>(<span style="color:#881350;">int</span>)tabs;<br />
- (<span style="color:#400080;">NSString</span>*)<span style="color:#6c0540;">xml</span>;</div>
<p>Now for the best part of the library, which is the ability to read in XML and represent it in APXML. All you have to execute is one simple line:</p>
<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; ">&nbsp;&nbsp;&nbsp;&nbsp;APDocument *doc = [APDocument <span style="color:#6c0540;">documentWithXMLString:</span>xmlString];</div>
<p>Hopefully this will be helpful to other developers out there. I may post another article soon if anybody has some questions.</p>
<p><strong>UPDATE Sep 5, 2009:</strong> Here&#8217;s an example that demonstrates traversing the XML document.</p>
<div style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; ">&nbsp;&nbsp;&nbsp;&nbsp;APElement *rootElement = [doc <span style="color:#6c0540;">rootElement</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSLog</span>(<span style="color:#760f15;">@&quot;Root Element Name: %@&quot;</span>, rootElement.name);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;">// get all the child elements (each book)<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSArray</span> *childElements = [rootElement <span style="color:#6c0540;">childElements</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#881350;">for</span><span style="color:#003369;"> </span>(APElement *child in childElements)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;">// returns the tag name<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSLog</span>(<span style="color:#760f15;">@&quot;Child Name: %@&quot;</span>, child.name);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;">// reads the attribute named &#8216;author&#8217;<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSLog</span>(<span style="color:#760f15;">@&quot;Author: %@&quot;</span>, [child <span style="color:#6c0540;">valueForAttributeNamed:</span><span style="color:#760f15;">@&quot;author&quot;</span>]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#236e25;">// returns the text content of the element<br />
</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#400080;">NSLog</span>(<span style="color:#760f15;">@&quot;Title: %@&quot;</span>, [child <span style="color:#6c0540;">value</span>]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}</div>
<p>In the console you&#8217;ll see (I&#8217;ve removed the <code>NSLog</code> markup):</p>
<div style="overflow:auto;">
<pre>
Root Element Name: books
Child Name: book
Author: Michael Pollan
Title: The Omnivore’s Dilemma
Child Name: book
Author: Foley, van Dam, Feiner, Hughes
Title: Computer Graphics: Principles and Practices
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://arashpayan.com/blog/index.php/2009/01/14/apxml-nsxmldocument-substitute-for-iphoneipod-touch/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
