<?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>Codec &#187; nil</title>
	<atom:link href="http://www.trembl.org/codec/tag/nil/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.trembl.org/codec</link>
	<description>A Personal Polylogic Code/Decode &#039;Zettelkasten&#039;</description>
	<lastBuildDate>Thu, 02 Feb 2012 03:38:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>UIAlertViews additional Buttons</title>
		<link>http://www.trembl.org/codec/583/</link>
		<comments>http://www.trembl.org/codec/583/#comments</comments>
		<pubDate>Sun, 09 May 2010 03:22:48 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[nil]]></category>
		<category><![CDATA[UIAlertView]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/583/</guid>
		<description><![CDATA[UIAlertView *alert = &#91;&#91;UIAlertView alloc&#93; initWithTitle:@&#34;Hello&#34; message:@&#34;Do you really want to?&#34; delegate:self cancelButtonTitle:@&#34;Cancel&#34; otherButtonTitles:@&#34;OK&#34;, nil&#93;; The intuively unobvious thing is, that otherButtonTitles requires a nil-terminated, comma-seperated list(?) of NSStrings. Although you can add (any number?) of additional buttons, it gets silly after about 3. Another thing to note is that in the case of two [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">UIAlertView <span style="color: #002200;">*</span>alert <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIAlertView alloc<span style="color: #002200;">&#93;</span>
	 initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Hello&quot;</span>
	 message<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Do you really want to?&quot;</span>
	 delegate<span style="color: #002200;">:</span>self
	 cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cancel&quot;</span> 
	 otherButtonTitles<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;OK&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>The intuively unobvious thing is, that <em>otherButtonTitles</em> requires a nil-terminated, comma-seperated list(?) of NSStrings.</p>
<p>Although you can add (any number?) of additional buttons, it gets silly after about 3.</p>
<p>Another thing to note is that in the case of two buttons, they get displayed side by side, whereas one button or more than two are shown vertically stacked.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/583/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NSMutableArray: setObject vs. setValue</title>
		<link>http://www.trembl.org/codec/214/</link>
		<comments>http://www.trembl.org/codec/214/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 03:53:18 +0000</pubDate>
		<dc:creator>Georg Tremmel</dc:creator>
				<category><![CDATA[Raw]]></category>
		<category><![CDATA[nil]]></category>
		<category><![CDATA[NSMutableArray]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[setObject]]></category>
		<category><![CDATA[setValue]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.trembl.org/codec/?p=214</guid>
		<description><![CDATA[Following situation Using TouchXML to parse XML data, works without problem on example XML files, but crahes on mine. Problem Empty values in my data set. (sometimes &#60;place&#62;somePlace&#60;/place&#62;, sometimes &#60;place&#62;&#60;/place&#62;) /* CXMLDocument setup &#38; parsing omitted */ NSString *e = &#91;&#91;resultElement childAtIndex:counter&#93; stringValue&#93;; NSString *k = &#91;&#91;resultElement childAtIndex:counter&#93; name&#93;; &#160; &#160; &#91;blogItem setObject:e forKey:k&#93;; // [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Following situation</strong> Using TouchXML to parse XML data, works without problem on example XML files, but crahes on mine.<br />
<strong>Problem</strong> Empty values in my data set. (sometimes &lt;place&gt;somePlace&lt;/place&gt;, sometimes &lt;place&gt;&lt;/place&gt;)</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">/* CXMLDocument setup &amp; parsing omitted */</span>
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>e <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>resultElement childAtIndex<span style="color: #002200;">:</span>counter<span style="color: #002200;">&#93;</span> stringValue<span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>k <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>resultElement childAtIndex<span style="color: #002200;">:</span>counter<span style="color: #002200;">&#93;</span> name<span style="color: #002200;">&#93;</span>;
&nbsp;
&nbsp;
<span style="color: #002200;">&#91;</span>blogItem setObject<span style="color: #002200;">:</span>e forKey<span style="color: #002200;">:</span>k<span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">// crashes when e is empty. Displays a (null), is nil</span></pre></div></div>

<p><strong>Solution 1</strong><br />
Check for empty e, replace nil with empty string</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// check if element is empty</span>
<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #a61390;">nil</span> <span style="color: #002200;">==</span> e <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>	<span style="color: #11740a; font-style: italic;">// ...or the less elegant (0 == [e length])</span>
	e <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span>;
<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#91;</span>blogItem setObject<span style="color: #002200;">:</span>e forKey<span style="color: #002200;">:</span>k<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p><strong>Solution 2</strong><br />
Use <em>setValue</em> instead of <em>setObject</em>, as setObject crashes and burns when it encounters nil, whereas setValue specifically deals only with strings and handles nil gracefully.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>blogItem setValue<span style="color: #002200;">:</span>e forKey<span style="color: #002200;">:</span>k<span style="color: #002200;">&#93;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.trembl.org/codec/214/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

