<?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>Vincent Gable's Blog &#187; Prometheus Development</title>
	<atom:link href="http://vgable.com/blog/tag/prometheus-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://vgable.com/blog</link>
	<description>my weblog.</description>
	<lastBuildDate>Thu, 11 Mar 2010 00:36:32 +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>Ignoring Just One Deprecated Warning</title>
		<link>http://vgable.com/blog/2009/06/15/ignoring-just-one-deprecated-warning/</link>
		<comments>http://vgable.com/blog/2009/06/15/ignoring-just-one-deprecated-warning/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 02:38:11 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Bug Bite]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Compilers]]></category>
		<category><![CDATA[GCC]]></category>
		<category><![CDATA[iPhone OS 3.0]]></category>
		<category><![CDATA[Project Management]]></category>
		<category><![CDATA[Prometheus Development]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2009/06/15/ignoring-just-one-deprecated-warning/</guid>
		<description><![CDATA[Switching projects over to iPhone OS 3.0 means discovering that functions I&#8217;m using are deprecated. Occasionally there isn&#8217;t a totally straightforward replacement, and the best thing to do is to file a bug/TODO/note for myself, and ignore the warning until a later version, when major refactoring will be possible. But bitter experience has taught me [...]]]></description>
			<content:encoded><![CDATA[<p>Switching projects over to iPhone OS 3.0 means discovering that functions I&#8217;m using are deprecated. Occasionally there isn&#8217;t a totally straightforward replacement, and the best thing to do is to <em>file a bug/TODO/note for myself</em>, and ignore the warning until a later version, when major refactoring will be possible. But bitter experience has taught me to have Xcode treat warnings as errors<sup>1</sup>, so it&#8217;s necessary to trick the compiler into ignoring the warning for things to build.</p>
<h3><code>-Wno-deprecated</code></h3>
<p>The <code><a href="http://developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/gcc/Warning-Options.html#Warning-Options">-Wno-deprecated</a></code> flag tells GCC to suppress warnings about deprecated code. But <a href="http://developer.apple.com/tools/xcode/xcodebuildsettings.html">adding it to an Xcode project</a> means you won&#8217;t get useful warnings about <em>other</em> depreciated code.</p>
<p>You could file a bug telling yourself to turn that warning back on after the deprecated functionality has been updated. That should work just fine. But it feels like bad project hygiene to me.</p>
<h3>Casting and Protocols</h3>
<p>Type casting is a dangerous old-C technique that&#8217;s <em>earned</em> its infamy. But it&#8217;s undeniably fitting to use a <a href="http://www.acm.org/crossroads/xrds3-1/ovp3-1.html">deprecated</a> language feature to get deprecated code to build. The basic idea is to declare a protocol that includes the method you want to suppress warnings for,</p>
<pre>
@protocol DeprecatedHack
- (void) myDeprecatedMethod;
@end
</pre>
<p>then just <em>cast</em> your objects so the compiler thinks they implement the protocol,</p>
<pre>
[foo myDeprecatedMethod]; //warnings
[(id&lt;DeprecatedHack&gt;>)foo myDeprecatedMethod]; //no warnings
</pre>
<p>Although having to declare a protocol is somewhat heavyweight, it leaves a nice artifact <em>in the code</em> reminding you to replace deprecated functionality.</p>
<h3>Protocols Not Required</h3>
<p>Sometimes just casting to <code>id</code> is enough. This happens if another object has a non-deprecated method with the same name. </p>
<p><sup>1</sup><small>For experimental or prototyping projects I let warnings slide. But in the main project I always treat warnings as errors. Ignoring them in production code has never worked &#8212; warnings fester and grow on each other.</p>
<p>Because Objective-C is so dynamic, there are many errors that the compiler can warn you about, but can&#8217;t be <em>totally sure</em> are errors. For example, methods can be added to a class at runtime, so if you call <code>-someMethodThatDoesNotExistAnywhere</code>, the compiler will warn you that something is up, but won&#8217;t stop the build, because the necessary code <em>could </em>magically appear at runtime. Of course, 99% of the time, it&#8217;s me accidentally using <code>count</code> when I meant <code>length</code>, etc. What I&#8217;m really trying to say here is that treating warnings as errors is an even better idea in Objective-C.</p>
<p></small></p>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2009/06/15/ignoring-just-one-deprecated-warning/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Early Adopters Wanted!</title>
		<link>http://vgable.com/blog/2009/06/11/early-adopters-wanted/</link>
		<comments>http://vgable.com/blog/2009/06/11/early-adopters-wanted/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 16:21:15 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Prometheus]]></category>
		<category><![CDATA[Prometheus Development]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2009/06/11/early-adopters-wanted/</guid>
		<description><![CDATA[I am wrapping up work on Prometheus, an iPhone app that edits the Simple English Wikipedia.
Unfortunately, I am having trouble finding people to take the pre-release version for a spin, and tell me what they think. I want to be sure I&#8217;ve fixed any glaring issues before I push my work out to the App [...]]]></description>
			<content:encoded><![CDATA[<p>I am wrapping up work on <a href="http://vgable.com/prometheus/">Prometheus</a>, an iPhone app that <em>edits</em> the <a href="http://simple.wikipedia.org">Simple English Wikipedia</a>.</p>
<p>Unfortunately, I am having trouble finding people to <a href="http://vgable.com/prometheus">take the pre-release version for a spin</a>, and tell me what they think. I want to be sure I&#8217;ve fixed any glaring issues before I push my work out to the App Store.</p>
<p>If you are interested in helping, please visit the <a href="http://vgable.com/prometheus/">Prometheus webpage</a>.</p>
<p>Thank you!</p>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2009/06/11/early-adopters-wanted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NSXMLParser and HTML/XHTML</title>
		<link>http://vgable.com/blog/2009/05/01/nsxmlparser-and-htmlxhtml/</link>
		<comments>http://vgable.com/blog/2009/05/01/nsxmlparser-and-htmlxhtml/#comments</comments>
		<pubDate>Sat, 02 May 2009 00:01:33 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Bug Bite]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[NSXMLParser]]></category>
		<category><![CDATA[Prometheus Development]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2009/05/01/nsxmlparser-and-htmlxhtml/</guid>
		<description><![CDATA[NSXMLParser converts HTML/XML-entities in the string it gives the delegate callback -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string. So if an XML file contains the string, "&#38;lt; or &#38;gt;", the converted string "&#60; or &#62;" would be reported to the delegate, not the string that you would see if you opened the file with TextEdit.
This is correct behavior [...]]]></description>
			<content:encoded><![CDATA[<p><code><a href="http://developer.apple.com/documentation/Cocoa/Conceptual/XMLParsing/index.html">NSXMLParser</a></code> converts HTML/XML-entities in the <code>string</code> it gives the delegate callback <a href="http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/parser:foundCharacters:"><code>-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string</code></a>. So if an XML file contains the string, <code>"&amp;lt; or &amp;gt;"</code>, the converted string <code>"&lt; or &gt;"</code> would be reported to the delegate, <em>not</em> the string that you would see if you opened the file with TextEdit.</p>
<p>This is correct behavior for XML files, but it can cause problems if you are trying to use an <code>NSXMLParser</code> to monkey with XHTML/HTML.</p>
<p>I was using an <code>NSXMLParser</code> to modify an XHTML webpage from <a href="http://simple.wikipedia.org/">Simple Wikipedia</a>, and it was turning: &#8220;<code>#include &amp;lt;stdio&amp;gt;</code>&#8221; into &#8220;<code>#include &lt;stdio&gt;</code>&#8220;, which then displayed as &#8220;<code>#include </code>&#8220;, because WebKit thought <code>&lt;stdio&gt;</code> was a tag.</p>
<h3>Solution: Better Tools</h3>
<p><strong>For scraping/reading a webpage, <a href="http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html">XPath is the best choice</a></strong>. It is faster and less memory intensive then <code>NSXMLParser</code>, and very concise. My experience with it has been positive.</p>
<p><strong>For modifying a webpage, JavaScript might be a better fit</strong> then Objective-C. You can use<br />
<a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIWebView_Class/Reference/Reference.html#//apple_ref/occ/instm/UIWebView/stringByEvaluatingJavaScriptFromString:"><code> - (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script</code></a> to execute JavaScript inside a <code>UIWebView</code> in any Cocoa program. Neat stuff!</p>
<h3>My Unsatisfying Solution</h3>
<p><strong>Do not use this, see why below:</strong></p>
<pre>
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string;
{
	string = [string stringByReplacingOccurrencesOfString:@"<" withString:@"&amp;lt;"];
	string = [string stringByReplacingOccurrencesOfString:@">" withString:@"&amp;gt;"];

	/* ... rest of the method */
}
</pre>
<p>Frankly that code scares me.  I worry I&#8217;m not escaping something I should be. Experience has taught me I don&#8217;t have the experience of the teams who wrote HTML libraries, so it&#8217;s dangerous to try and recreate their work.</p>
<p>(UPDATED 2009-05-26: And indeed, I screwed up. I was replacing <code>&amp;</code> with <code>&amp;amp;</code>, and that was causing trouble. While my &#8220;fix&#8221; of not converting <code>&amp;</code> seems to work on <em>one website</em>, it will not in general.)</p>
<p>I would like to experiment with using JavaScript instead of an <code>NSXMLParser</code>, but at the moment I have a working (and surprisingly compact) <code>NSXMLParser</code> implementation, and much less familiarity with JavaScript then Objective-C. And compiled Obj-C code should be more performant then JavaScript.  So I&#8217;m sticking with what I have, at least until I&#8217;ve gotten Prometheus 1.0 out the door.</p>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2009/05/01/nsxmlparser-and-htmlxhtml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
