<?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>KDBDallas &#187; Objective-C</title>
	<atom:link href="http://kdbdallas.com/tag/objective-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://kdbdallas.com</link>
	<description>Mac and iPhone Developer, Lacrosse Fan and Coach, Husband, Father, all in one</description>
	<lastBuildDate>Fri, 13 Jan 2012 21:35:25 +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>The Complete Friday Q&amp;A by Mike Ash</title>
		<link>http://kdbdallas.com/2011/01/27/the-complete-friday-qa-by-mike-ash/</link>
		<comments>http://kdbdallas.com/2011/01/27/the-complete-friday-qa-by-mike-ash/#comments</comments>
		<pubDate>Fri, 28 Jan 2011 04:31:38 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Cocoa Touch]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://kdbdallas.com/?p=367</guid>
		<description><![CDATA[Mike Ash has turned his famous Friday Question and Answer series into a book, available in either iBooks or Kindle versions. Mike is an amazingly smart guy, who knows more about programming then you could ever imagine. If you work with Objective-C you owe it to yourself to check out his book and his site.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mikeash.com/pyblog/">Mike Ash</a> has turned his famous Friday Question and Answer series <a href="http://www.mikeash.com/pyblog/complete-friday-qa-now-available.html">into a book</a>, available in either <a href="http://itunes.apple.com/us/book/the-complete-friday-q-a-volume/id417272297">iBooks</a> or <a href="http://www.amazon.com/Complete-Friday-ebook/dp/B004KZQ0LO/ref=sr_1_14?ie=UTF8&#038;qid=1296154100&#038;sr=8-14">Kindle</a> versions.</p>
<p>Mike is an amazingly smart guy, who knows more about programming then you could ever imagine.</p>
<p>If you work with Objective-C you owe it to yourself to check out his book and his site.</p>
]]></content:encoded>
			<wfw:commentRss>http://kdbdallas.com/2011/01/27/the-complete-friday-qa-by-mike-ash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Log all accessed methods in Objective-C with DTrace</title>
		<link>http://kdbdallas.com/2009/02/07/log-all-accessed-methods-in-objective-c-with-dtrace/</link>
		<comments>http://kdbdallas.com/2009/02/07/log-all-accessed-methods-in-objective-c-with-dtrace/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 07:10:46 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Cocoa Touch]]></category>
		<category><![CDATA[DTrace]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://kdbdallas.com/?p=173</guid>
		<description><![CDATA[I have recently been debugging some Objective-C and Cocoa/Cocoa Touch code. Not being familiar with all the code and with a TON of methods being accessed in milliseconds, my attempts at stepping through the code just wasn&#8217;t working, as clicking &#8216;Step Into&#8217; as fast as I could keep up and over an hour of stepping [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been debugging some Objective-C and Cocoa/Cocoa Touch code.</p>
<p>Not being familiar with all the code and with a TON of methods being accessed in milliseconds, my attempts at stepping through the code just wasn&#8217;t working, as clicking &#8216;Step Into&#8217; as fast as I could keep up and over an hour of stepping through I was still not even close to figuring out what I needed to know.</p>
<p>This lead me to the thought of logging every method that was accessed and then I could step look through it and skip around as needed.<br />
However with 60 some odd files and say maybe 20 methods in each file, that would take a lot of NSLog&#8217;s.<br />
I started looking around and was pointed to bbums blog about <a href="http://www.friday.com/bbum/2008/01/01/objective-c-a-hack-to-log-all-methods/">doing something similar</a>.<br />
However it still would take adding some code, plus I couldn&#8217;t get it working right with the iPhone.</p>
<p>This lead me to wonder about <a href="http://en.wikipedia.org/wiki/Dtrace">DTrace</a>.<br />
After a recent podcast from <a href="http://twitter.com/macdevnet">Scotty</a> at the <a href="http://www.mac-developer-network.com/">Mac Developer Network</a>, featuring <a href="http://cocoasamurai.blogspot.com/">Colin Wheeler</a> talking about DTrace, I have been very interested in learning more about DTrace.</p>
<p>The difficult thing I have been finding is that since DTrace was originally written for Sun, it is hard to find info related to MacOS and more so Cocoa.</p>
<p>I then found a video from Colin about using DTrace with Cocoa and XCode.<br />
<a href="http://www.viddler.com/explore/Machx/videos/8">http://www.viddler.com/explore/Machx/videos/8</a></p>
<p>I wasn&#8217;t able to get what I wanted working, so I hit <a href="http://twitter.com/CocoaSamurai">Colin up on Twitter</a> and then talked to him a bit in email and he pointed me to the <strong>Golden Solution</strong>!</p>
<p>The solution is:<br />
<code>objc$target:::entry{}</code></p>
<p>So I took that and created a DTrace script.<br />
You can grab it here:<br />
<a href='http://kdbdallas.com/wp-content/uploads/2009/02/logallmethodsd.zip'>http://kdbdallas.com/wp-content/uploads/2009/02/logallmethodsd.zip</a></p>
<p>To run it open Terminal and run:<br />
sudo ./logAllMethods.d -p PID</p>
<p>Of course replacing &#8216;PID&#8217; with the PID of your running program and remembering that for DTrace &#8216;sudo&#8217; is required.</p>
<p>Also note that this works for iPhone programs running in the iPhone Simulator.<br />
Just look for the PID of your iPhone app within Activity Monitor once it&#8217;s running in the simulator.</p>
<p>Be careful as depending on the program it can spit out a TON of data VERY quickly.</p>
<p>Running this against Adium for only a fraction of a second gave me a couple hundred lines of output.</p>
<p>The output looks like this:</p>
<p>tesseract:Desktop dallas$ sudo ./logAllMethods.d -p 4371<br />
dtrace: script &#8216;./logAllMethods.d&#8217; matched 71222 probes<br />
CPU     ID                    FUNCTION:NAME<br />
  0  59398                    -retain:entry<br />
  0  34684                    +retain:entry<br />
  0  32061            +idleAllMovies::entry<br />
  0  32062                      -idle:entry<br />
  0  34707                    -retain:entry<br />
  0  32914       -_usingVisualContext:entry<br />
  0  32878        -_resyncNaturalSize:entry<br />
  0  31935                 -loadState:entry<br />
  0  31972               -naturalSize:entry</p>
<p>Hopefully this helps someone out there.<br />
Just remember always use the info I post for good.<br />
(or if its for evil make sure it profitable and then send me a cut)</p>
<p>Once again, special thanks to Colin Wheeler.</p>
]]></content:encoded>
			<wfw:commentRss>http://kdbdallas.com/2009/02/07/log-all-accessed-methods-in-objective-c-with-dtrace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac/iPhone: Show Available Usable Disk Space</title>
		<link>http://kdbdallas.com/2008/12/27/maciphone-show-availble-useable-diskspace/</link>
		<comments>http://kdbdallas.com/2008/12/27/maciphone-show-availble-useable-diskspace/#comments</comments>
		<pubDate>Sun, 28 Dec 2008 00:18:53 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://kdbdallas.com/?p=102</guid>
		<description><![CDATA[If you have an application that allows users to upload content to the app, you might want to show the user how much space is available for them to use. This is especially true on the iPhone where it is not as easy for the user to quickly check if they have enough room to [...]]]></description>
			<content:encoded><![CDATA[<p>If you have an application that allows users to upload content to the app, you might want to show the user how much space is available for them to use.</p>
<p>This is especially true on the iPhone where it is not as easy for the user to quickly check if they have enough room to upload a given file.</p>
<p>You may also want to check if there is enough space before you start the upload, so you can inform them that the file wont fit.</p>
<p>That brings you to the task of figuring out how much free space there is, and more importantly how much free space is left that you as an unprivileged program can access.</p>
<p>The following code is based towards the iPhone, however all that would be needed to change it to be used on the Mac is the location you are checking for free space, and the setting of the label.</p>
<p><strong>NOTE:</strong> <em>The below &#8220;shown&#8221; code is old. The updated code is in the zip file at the bottom</em></p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#include &lt;sys/param.h&gt;</span>
<span style="color: #6e371a;">#include &lt;sys/mount.h&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>sizeType;
&nbsp;
<span style="color: #a61390;">float</span> availableDisk;
&nbsp;
<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>paths <span style="color: #002200;">=</span> NSSearchPathForDirectoriesInDomains<span style="color: #002200;">&#40;</span>NSDocumentDirectory, NSUserDomainMask, <span style="color: #a61390;">YES</span><span style="color: #002200;">&#41;</span>;
&nbsp;
<span style="color: #a61390;">struct</span> statfs tStats;
&nbsp;
statfs<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>paths lastObject<span style="color: #002200;">&#93;</span> cString<span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&amp;</span>tStats<span style="color: #002200;">&#41;</span>;
&nbsp;
availableDisk <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">float</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#40;</span>tStats.f_bavail <span style="color: #002200;">*</span> tStats.f_bsize<span style="color: #002200;">&#41;</span>;
&nbsp;
<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>availableDisk &gt; <span style="color: #2400d9;">1024</span><span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">//Kilobytes</span>
	availableDisk <span style="color: #002200;">=</span> availableDisk <span style="color: #002200;">/</span> <span style="color: #2400d9;">1024</span>;
&nbsp;
	sizeType <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot; KB&quot;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>availableDisk &gt; <span style="color: #2400d9;">1024</span><span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">//Megabytes</span>
	availableDisk <span style="color: #002200;">=</span> availableDisk <span style="color: #002200;">/</span> <span style="color: #2400d9;">1024</span>;
&nbsp;
	sizeType <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot; MB&quot;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>availableDisk &gt; <span style="color: #2400d9;">1024</span><span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">//Gigabytes</span>
	availableDisk <span style="color: #002200;">=</span> availableDisk <span style="color: #002200;">/</span> <span style="color: #2400d9;">1024</span>;
&nbsp;
	sizeType <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot; GB&quot;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
diskSpaceLbl.text <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Available Disk Space: &quot;</span> stringByAppendingFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%.2f&quot;</span>, availableDisk<span style="color: #002200;">&#93;</span> stringByAppendingString<span style="color: #002200;">:</span>sizeType<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>This will give you something like the following:</p>
<p><img class="alignnone size-full wp-image-104" title="availablediskspace" src="http://kdbdallas.com/wp-content/uploads/2008/12/availablediskspace.png" alt="availablediskspace" width="257" height="29" /></p>
<p><strong><em>UPDATE:</em></strong><br />
I have gone a step further and made this into an easy to use class, that works out of the box with the iPhone and the Mac.</p>
<p><a href='http://www.kdbdallas.com/Code/FSStats.zip'><img src="http://kdbdallas.com/wp-includes/images/crystal/archive.png"/></a> <a href='http://www.kdbdallas.com/Code/FSStats.zip'>FSStats.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kdbdallas.com/2008/12/27/maciphone-show-availble-useable-diskspace/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Cocoa: Adding an application to Login Items in Mac OS X Leopard</title>
		<link>http://kdbdallas.com/2008/09/30/adding-an-application-to-login-items-in-mac-os-x-leopard/</link>
		<comments>http://kdbdallas.com/2008/09/30/adding-an-application-to-login-items-in-mac-os-x-leopard/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 09:01:19 +0000</pubDate>
		<dc:creator>Dallas</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[Login Items]]></category>
		<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://kdbdallas.com/?p=54</guid>
		<description><![CDATA[In Mac OS X 10.5 Apple added a new set of API&#8217;s for adding an application to the users login items in Cocoa. In looking for the way to use this new API, I stumbled upon Justin Williams&#8217; blog carpeaqua.com where Justin was nice enough to put together a code example project showing just how [...]]]></description>
			<content:encoded><![CDATA[<p>In Mac OS X 10.5 Apple added a new set of API&#8217;s for adding an application to the users login items in Cocoa.</p>
<p>In looking for the way to use this new API, I stumbled upon Justin Williams&#8217; blog <a title="carpeaqua.com" href="http://log.carpeaqua.com/">carpeaqua.com</a> where Justin was nice enough to put together a code example project showing just how to use this new API.</p>
<p>You can grab the sample project at his public code repository <a title="http://secondgear-public.googlecode.com/svn/trunk/SGLaunchAtLogin/" href="http://secondgear-public.googlecode.com/svn/trunk/SGLaunchAtLogin/">http://secondgear-public.googlecode.com/svn/trunk/SGLaunchAtLogin/</a></p>
<p>Thanks again to Justin for making this available.</p>
<p>Hopefully this page helps with his Google position for people searching for this info.</p>
<p>Read his full post at: <a title="http://log.carpeaqua.com/post/27727810/adding-an-application-to-login-items-in-mac-os-x" href="http://log.carpeaqua.com/post/27727810/adding-an-application-to-login-items-in-mac-os-x">http://log.carpeaqua.com/post/27727810/adding-an-application-to-login-items-in-mac-os-x</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kdbdallas.com/2008/09/30/adding-an-application-to-login-items-in-mac-os-x-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

