<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>The WP Guru</title>
	
	<link>http://wpguru.co.uk</link>
	<description>Complicated Stuff. Made Simple.</description>
	<lastBuildDate>Mon, 17 Jun 2013 18:25:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
<!-- podcast_generator="Blubrry PowerPress/4.0.8" -->
	<itunes:summary>Complicated Stuff. Made Simple.</itunes:summary>
	<itunes:author>Jay Versluis</itunes:author>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://wpguru.co.uk/wp-content/uploads/2013/02/WP-Guru-Logo-iTunes-Logo.jpg" />
	<itunes:owner>
		<itunes:name>Jay Versluis</itunes:name>
		<itunes:email>jay@versluis.com</itunes:email>
	</itunes:owner>
	<managingEditor>jay@versluis.com (Jay Versluis)</managingEditor>
	<copyright>2013 by Jay Versluis</copyright>
	<itunes:subtitle>Complicated Stuff. Made Simple.</itunes:subtitle>
	<itunes:keywords>WordPress, Dreamweaver, iOS Development, php, mySQL, JavaScript, How-To, how to</itunes:keywords>
	<image>
		<title>The WP Guru</title>
		<url>http://wpguru.co.uk/wp-content/uploads/2013/02/WP-Guru-Logo-iTunes-Logo.jpg</url>
		<link>http://wpguru.co.uk</link>
	</image>
	<itunes:category text="Technology">
		<itunes:category text="Software How-To" />
	</itunes:category>
		<rawvoice:location>Miami Beach, FL</rawvoice:location>
		<rawvoice:frequency>weekly(ish)</rawvoice:frequency>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/wpguru-co-uk" /><feedburner:info uri="wpguru-co-uk" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>wpguru-co-uk</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>How to define a method that takes multiple parameters</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/O67C8GQU3L8/</link>
		<comments>http://wpguru.co.uk/2013/06/how-to-define-a-method-that-takes-multiple-parameters/#comments</comments>
		<pubDate>Mon, 17 Jun 2013 18:25:15 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-define-a-method-that-takes-multiple-parameters/</guid>
		<description><![CDATA[I keep forgetting how to do this&#8230; don&#8217;t ask me why, it&#8217;s not that difficult! So here&#8217;s how we define one: - (void)methodName:(NSString *)parameterOne methodNameContinues:(NSString *)parameterTwo; Add more parameters as you please. In theory, the method name is split across these multiple descriptive parts before each parameter is defined. However in reality I find it [...]]]></description>
				<content:encoded><![CDATA[<p>I keep forgetting how to do this&#8230; don&#8217;t ask me why, it&#8217;s not that difficult! So here&#8217;s how we define one:</p>
<pre class="wp-code-highlight prettyprint">
- (void)methodName:(NSString *)parameterOne methodNameContinues:(NSString *)parameterTwo;
</pre>
<p>Add more parameters as you please. In theory, the method name is split across these multiple descriptive parts before each parameter is defined. However in reality I find it easier to just repeat the parameter names in each section, like this:</p>
<pre class="wp-code-highlight prettyprint">
- (void)methodName:(NSString *)theString nextString:(NSString *)theNextString;

or

- (void)callingNames:(NSString *)firstName lastName:(NSString *)lastName;
</pre>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/O67C8GQU3L8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/06/how-to-define-a-method-that-takes-multiple-parameters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/06/how-to-define-a-method-that-takes-multiple-parameters/</feedburner:origLink></item>
		<item>
		<title>How to list the contents of an NSURL</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/Hj5ya47zHIE/</link>
		<comments>http://wpguru.co.uk/2013/06/how-to-list-the-contents-of-an-nsurl/#comments</comments>
		<pubDate>Sun, 16 Jun 2013 02:28:32 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSFileManager]]></category>
		<category><![CDATA[NSURL]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-list-the-contents-of-an-nsurl/</guid>
		<description><![CDATA[On the iOS simulator we have the luxury of peeking inside our virtual devices with the Finder. We can do this by heading over to the Finder, holding down Option and clicking Go. This will bring up the Library, in which you can navigate to Application Support / iPhone Simulator / 7.0 / Applications / [...]]]></description>
				<content:encoded><![CDATA[<p>On the iOS simulator we have the luxury of peeking inside our virtual devices with the Finder. We can do this by heading over to the Finder, holding down Option and clicking Go. This will bring up the Library, in which you can navigate to Application Support / iPhone Simulator / 7.0 / Applications / followed by a weird string. One of those will contain your app and all its directories.</p>
<p>But on a real device we&#8217;re not so lucky. Has a file really been copied the way we intended it to? NSFileManager to the rescue! Here&#8217;s how to read out the contents of a directory at an NSURL:</p>
<pre class="wp-code-highlight prettyprint">
NSArray *contents = [[NSArray alloc]init];
contents =[[NSFileManager defaultManager]contentsOfDirectoryAtURL:yourURL includingPropertiesForKeys:nil options:nil error:nil];
    
NSLog(@&quot;%@&quot;, contents);
</pre>
<p>contentsOfDirectoryAtURL returns an NSArray (of NSURLs) which you can loop through and display any way you like. If you have a file path instead, you can use contentsOfDirectoryAtPath instead.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/Hj5ya47zHIE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/06/how-to-list-the-contents-of-an-nsurl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/06/how-to-list-the-contents-of-an-nsurl/</feedburner:origLink></item>
		<item>
		<title>How to display a UIImage from an NSURL</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/gGqidytPwHY/</link>
		<comments>http://wpguru.co.uk/2013/06/how-to-display-a-uiimage-from-an-nsurl/#comments</comments>
		<pubDate>Sat, 15 Jun 2013 22:10:58 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSURL]]></category>
		<category><![CDATA[UIImage]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-display-a-uiimage-from-an-nsurl/</guid>
		<description><![CDATA[If you&#8217;re displaying images from the main iOS bundle, things are fairly straightforward: self.imageView.image = [UIImage imageNamed:@"Amy.png"]; But if you have an NSURL to your image then it&#8217;s not as easy. It took me some digging to find out that you have to convert the URL into NSData first, and then display the data: NSData [...]]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re displaying images from the main iOS bundle, things are fairly straightforward:</p>
<pre class="wp-code-highlight prettyprint">
self.imageView.image = [UIImage imageNamed:@&quot;Amy.png&quot;];
</pre>
<p>But if you have an NSURL to your image then it&#8217;s not as easy. It took me some digging to find out that you have to convert the URL into NSData first, and then display the data:</p>
<pre class="wp-code-highlight prettyprint">
NSData *imageData = [NSData dataWithContentsOfURL:destinationURL];
self.imageView.image = [UIImage imageWithData:imageData];
</pre>
<p>Convoluted &#8211; but currently the only way I know how to do it.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/gGqidytPwHY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/06/how-to-display-a-uiimage-from-an-nsurl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/06/how-to-display-a-uiimage-from-an-nsurl/</feedburner:origLink></item>
		<item>
		<title>How to copy a file from the Main Bundle into the Documents Directory in iOS</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/MIFrmTv2xFc/</link>
		<comments>http://wpguru.co.uk/2013/06/how-to-copy-a-file-from-the-main-bundle-into-the-documents-directory-in-ios/#comments</comments>
		<pubDate>Sat, 15 Jun 2013 21:43:52 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSFileManager]]></category>
		<category><![CDATA[NSURL]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-copy-a-file-from-the-main-bundle-into-the-documents-directory-in-ios/</guid>
		<description><![CDATA[You can do this either by using paths or NSURLs. Apple recommends using NSURLs, so here&#8217;s how it works. In this example we&#8217;re copying a file called &#8220;Amy.png&#8221; which exists in the app&#8217;s main bundle. // file URL in our bundle NSURL *fileFromBundle = [[NSBundle mainBundle]URLForResource:@"Amy" withExtension:@"png"]; // Destination URL NSURL *destinationURL = [[self applicationDocumentsDirectory]URLByAppendingPathComponent:@"Amy.png"]; [...]]]></description>
				<content:encoded><![CDATA[<p>You can do this either by using paths or NSURLs. Apple recommends using NSURLs, so here&#8217;s how it works. </p>
<p>In this example we&#8217;re copying a file called &#8220;Amy.png&#8221; which exists in the app&#8217;s main bundle.</p>
<pre class="wp-code-highlight prettyprint">
// file URL in our bundle
NSURL *fileFromBundle = [[NSBundle mainBundle]URLForResource:@&quot;Amy&quot; withExtension:@&quot;png&quot;];
    
// Destination URL
NSURL *destinationURL = [[self applicationDocumentsDirectory]URLByAppendingPathComponent:@&quot;Amy.png&quot;];
    
// copy it over
[[NSFileManager defaultManager]copyItemAtURL:fileFromBundle toURL:destinationURL error:nil];
</pre>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/MIFrmTv2xFc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/06/how-to-copy-a-file-from-the-main-bundle-into-the-documents-directory-in-ios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/06/how-to-copy-a-file-from-the-main-bundle-into-the-documents-directory-in-ios/</feedburner:origLink></item>
		<item>
		<title>How to use Core Data with multiple Store Files</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/Q2KBNOAoXwg/</link>
		<comments>http://wpguru.co.uk/2013/06/how-to-use-core-data-with-multiple-store-files/#comments</comments>
		<pubDate>Wed, 12 Jun 2013 01:03:39 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Core Data]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-use-core-data-with-multiple-store-files/</guid>
		<description><![CDATA[Sometimes it can be useful to split your Core Data Store File across multiple files. For example, one file could live on the local file system, while the other could live in iCloud. We can do this by telling the Xcode Model Editor to add more than one Configuration, each of which can be allocated [...]]]></description>
				<content:encoded><![CDATA[<p>Sometimes it can be useful to split your Core Data Store File across multiple files. For example, one file could live on the local file system, while the other could live in iCloud.</p>
<p>We can do this by telling the Xcode Model Editor to add more than one Configuration, each of which can be allocated certain Entities. Each Configuration can be configured to use a separate store file.</p>
<p>Consider this example code which is provided by the Xcode 4.6 templates to initiate the Persistent Store Coordinator:</p>
<pre class="wp-code-highlight prettyprint">
    // Single Store - original code provided with template
    NSURL *url = [applicationFilesDirectory URLByAppendingPathComponent:@&quot;Two_Stores.storedata&quot;];
    NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom];
    if (![coordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:url options:nil error:&amp;error]) {
        [[NSApplication sharedApplication] presentError:error];
        return nil;
    }
</pre>
<p>Notice the absence of a Configuration in the addPersistentStoreWithType method. You can create Configurations by click-holding the big PLUS button that let&#8217;s you add Entities by default. GIve them a meaningful name, then drag-and-drop in your Entities:</p>
<p><a href="http://pinkstone.co.uk/wp-content/uploads/2013/04/Two-Stores-Model-Editor.png"><img src="http://pinkstone.co.uk/wp-content/uploads/2013/04/Two-Stores-Model-Editor-600x570.png" alt="Two Stores Model Editor" width="600" height="570" class="alignnone size-large wp-image-762" /></a></p>
<p>Next you&#8217;ll replace the code above with something like this, adding more than one store file to your Persistent Store Coordinator:</p>
<pre class="wp-code-highlight prettyprint">
    // create URLs for each store
    NSURL *url1 = [applicationFilesDirectory URLByAppendingPathComponent:@&quot;Store-One.xml&quot;];
    NSURL *url2 = [applicationFilesDirectory URLByAppendingPathComponent:@&quot;Store-Two.xml&quot;];
    
    // create the coordinator
    NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom];
    
    // add store files to coordinator
    if (![coordinator addPersistentStoreWithType:NSXMLStoreType configuration:@&quot;Configuration1&quot; URL:url1 options:nil error:&amp;error]) {
        [[NSApplication sharedApplication] presentError:error];
        return nil;
    }
    
    if (![coordinator addPersistentStoreWithType:NSXMLStoreType configuration:@&quot;Configuration2&quot; URL:url2 options:nil error:&amp;error]) {
        [[NSApplication sharedApplication] presentError:error];
        return nil;
    }
</pre>
<p>Now you&#8217;ll work with two store files in the same Managed Object Context. This also means that whatever operation you call on the context (save for example) will be executed on both store files.</p>
<h3>Demo Project</h3>
<p>I&#8217;ve added a Demo Project to GitHub which demonstrates this in Mac OS X:</p>
<ul>
<li><a href="https://github.com/versluis/Two-Stores" rel="nofollow">https://github.com/versluis/Two-Stores</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/Q2KBNOAoXwg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/06/how-to-use-core-data-with-multiple-store-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/06/how-to-use-core-data-with-multiple-store-files/</feedburner:origLink></item>
		<item>
		<title>How to style the Tumblr Widget Sidebar Plugin</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/NxExCeykXhs/</link>
		<comments>http://wpguru.co.uk/2013/06/how-to-style-the-tumblr-widget-sidebar-plugin/#comments</comments>
		<pubDate>Wed, 05 Jun 2013 14:22:56 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://wpguru.co.uk/?p=3283</guid>
		<description><![CDATA[I&#8217;ve been recently using Tumblr more to post sketches from all kinds of devices, and naturally I wanted to embed them in some of my websites&#8217; sidebars. I found the extremely helpful Tumblr Widget plugin by Gabriel Roth for this: install, drag in the widget add Tumblr URL. Done! I wanted my images to be [...]]]></description>
				<content:encoded><![CDATA[<p></p><p><img src="http://wpguru.co.uk/wp-content/uploads/2013/06/tumblr-logo-150x150.png" alt="tumblr-logo" width="150" height="150" class="alignright size-thumbnail wp-image-3285" />I&#8217;ve been recently using <a href="http://versluis.tumblr.com" target="_blank">Tumblr</a> more to post sketches from all kinds of devices, and naturally I wanted to embed them in some of my websites&#8217; sidebars. </p>
<p>I found the extremely helpful <a href="http://wordpress.org/plugins/tumblr-widget-for-wordpress/" target="_blank">Tumblr Widget plugin</a> by Gabriel Roth for this: install, drag in the widget add Tumblr URL. Done!</p>
<p>I wanted my images to be in a size that the widget didn&#8217;t offer, so I did some tweaking &#8211; perhaps it&#8217;ll help if you&#8217;re in a similar situation.</p>
<p><span id="more-3283"></span></p>
<h3>Tweak the Image Size</h3>
<p>My sidebar is 250px wide, but the plugin only offers either 100px or 250px. The latter would be too wide for my sidebar, the former would be too small. So I chose to go with 250px for a decent image size and then override the CSS with the following code (this goes at the bottom of your style.css file):</p>
<p><code>.tumblr_post img {width: 225px; height: auto;}</code></p>
<p>This will retain the aspect ratio of the image and make it slightly narrower. Play with the value and see what works best for you.</p>
<h3>Removing Text</h3>
<p>I&#8217;m posting pictures to Tumblr and didn&#8217;t want to see any descriptions that I may put from time to time. To remove all other text from the widget add this bit of CSS:</p>
<p><code>.tumblr_post p {display: none;}</code></p>
<p>This will suppress all text output that&#8217;s wrapped in p tags (may not be what you want but works well for me).</p>
<p>And there you have it! See my changes live in the sidebar at <a href="http://www.versluis.com" target="_blank">www.versluis.com</a>, or see what I&#8217;m up to on <a href="http://versluis.tumblr.com" target="_blank">Tumblr</a> these days.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/NxExCeykXhs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/06/how-to-style-the-tumblr-widget-sidebar-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/06/how-to-style-the-tumblr-widget-sidebar-plugin/</feedburner:origLink></item>
		<item>
		<title>MySQL Replication Troubleshooting</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/8wrOUJmwfuc/</link>
		<comments>http://wpguru.co.uk/2013/05/mysql-replication-troubleshooting/#comments</comments>
		<pubDate>Mon, 13 May 2013 22:38:59 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://wpguru.co.uk/?p=3263</guid>
		<description><![CDATA[Sometimes things don&#8217;t work out with replication. When I first started experimenting with it I thought this was a &#8220;setup and forget about it&#8221; kind of job. Experience has shown though that you have to regularly triple check and see if things may have broken (despite a good and once working setup). Let&#8217;s take a [...]]]></description>
				<content:encoded><![CDATA[<p></p><p><img class="alignright size-full wp-image-1208" alt="crab-icon" src="http://wpguru.co.uk/wp-content/uploads/2011/03/crab-icon.png" width="128" height="128" />Sometimes things don&#8217;t work out with replication. When I first started experimenting with it I thought this was a &#8220;setup and forget about it&#8221; kind of job.</p>
<p>Experience has shown though that you have to regularly triple check and see if things may have broken (despite a good and once working setup).</p>
<p>Let&#8217;s take a look at what you can do when your Slave isn&#8217;t replicating anymore. If you want to know more about how to setup replication, have a look at <a href="http://wpguru.co.uk/2013/05/how-to-setup-mysql-masterslave-replication-with-existing-data/">my previous article</a> in which I explain how this works.</p>
<p><span id="more-3263"></span></p>
<h3>Master Troubleshooting</h3>
<p>Replication problems on your Slave do not usually indicate a fault on the Master; as long as it&#8217;s creating a log, all is well. You can check this by issuing a couple of &#8220;show master status&#8221; commands in 30 second intervals and see the log position change.</p>
<p>Provided data is being created or changed, the log positions should be different. If no log status shows up, then you&#8217;re being told that &#8220;binary loggin is disabled&#8221; &#8211; in which case you need to update your my.cnf file (see my <a href="http://wpguru.co.uk/2013/05/how-to-setup-mysql-masterslave-replication-with-existing-data/">other article</a> about this).</p>
<h3>Slave Troubleshooting</h3>
<p>More often replication fails because of something which isn&#8217;t working well on the Slave. Common scenarios include:</p>
<ul>
<li>login problems: wrong user/password/host combination</li>
<li>data import/synchronization problems</li>
<li>problematic statements</li>
<li>corrupt tables or databases</li>
</ul>
<p>Let&#8217;s go through these one by one. I intend to update this article if I find other problems (and solutions). Feel free to share your experiences in a comment at the bottom.</p>
<h3>How to check what&#8217;s bothering your Slave</h3>
<p>Your best place to see where something&#8217;s gone wrong is the MySQL log. On CentOS and many other Linux distributions that&#8217;s in <em><strong>/var/log/mysqld.log</strong></em> and you can check the last 10 lines with</p>
<pre class="wp-code-highlight prettyprint">tail /var/log/mysqld.log</pre>
<p>Not the easiest thing to read, but you get the basic idea of what the problem is.</p>
<h3>Slave can&#8217;t login to the Master</h3>
<p>Any issues pertaining to log data not being read, or connections not being possible are most certainly due to login problems.</p>
<p>See if you yourself can login to your Master as the replication user if you&#8217;ve set one up. Log in like this:</p>
<pre class="wp-code-highlight prettyprint">mysql -h domain+or+ip -u replicationuser -p</pre>
<p>If this isn&#8217;t possible then you need to look at your credentials on the Master. Perhaps the replication password is wrong, perhaps the user doesn&#8217;t have the &#8220;replication slave&#8221; privilege, or is not allowed to connect from your host.</p>
<p>You can always change your slave to use your root user momentarily to see if connections in general are possible. Note that this is not meant as a long term solution.</p>
<h3>Master and Slave are out of sync</h3>
<p>If you CAN login and your Slave still throws up errors then it&#8217;s usually because the Slave is trying to execute a command from the Master log and fails. For example, he may try to delete a database that doesn&#8217;t exist. Such things can happen if you&#8217;ve (accidentally) changed data on the Slave. That&#8217;s a big no-no.</p>
<p>It&#8217;s &#8220;read only&#8221;, all else is just a replica of the Master. Even though you can introduce new data onto the Slave, changing data that has been replicated from the Master will cause problems.</p>
<p>Sync problems can also occur when you didn&#8217;t restart MySQL on the Slave just after the big data import.</p>
<p>Lucky for us this is not a biggie though: simply stop the Slave, restart MySQL and give the your Slave the Master Log Coordinates manually (that&#8217;s why it&#8217;s handy to make a note of those).</p>
<p>You do it like this, obviously replacing the values with your own:</p>
<pre class="wp-code-highlight prettyprint">stop slave;

change master to 
MASTER_LOG_FILE = &#039;mysql-bin.000037&#039;, 
MASTER_LOG_POS = 14462;

start slave;</pre>
<h3>Corrupt Data on the Slave</h3>
<p>Sometimes tables or databases can get corrupt when they&#8217;re not properly closed. These things can happen on the Master &#8211; and as a result find their way onto the Slave, or something bad can happen on the Slave.</p>
<p>In either case, the Slave may not be able to process a statement and as a result will also stop and complain in his log.</p>
<p>To overcome this, you have two options:</p>
<ul>
<li>skip the bad statement and carry on</li>
<li>repairing the corrupt tables and carry on</li>
</ul>
<p>Let&#8217;s discuss how to tackle both.</p>
<h3>Skip a Statement or two (not recommended)</h3>
<p>This is the quick and dirty way of making the Slave ignore one (or several) Master log statements. This is not a problem if we&#8217;re dealing with disposable or temporary data &#8211; but it is a problem if you&#8217;re not (and frankly, who can really tell).</p>
<p>Be aware that skipping statements on the Slave will cause data inconsistencies &#8211; if these are noticeable or not depends entirely on your data and applications.</p>
<p>Here&#8217;s how you tell the Slave to skip the next 1 statement:</p>
<pre class="wp-code-highlight prettyprint">stop slave;
set global sql_slave_skip_counter = 1;
start slave;</pre>
<p>You can skip as many events as you like by increasing the value. Once the Slave is running again, go back to the log and see if processing goes well. Use this approach with extreme caution!</p>
<p>There&#8217;s an <a href="http://vitobotta.com/recovering-mysql-replication" target="_blank">interesting little script here by Vito Botta</a> on how to do this automatically.</p>
<h3>Repairing your Tables and Databases</h3>
<p>Ignoring a problem and hoping it doesn&#8217;t bite you later is never a good idea &#8211;  repairing what&#8217;s broken on the other hand sounds like a good plan.</p>
<p>You can repair single tables or databases with the &#8220;repair table&#8221; and &#8220;repair database&#8221; commands respectively &#8211; but what happens when you have hundreds of databases containing several thousand tables? You&#8217;d sit there all night issuing commands.</p>
<p>Lucky for us there&#8217;s a handy tool that does it for us:</p>
<ul>
<li>mysqlcheck &#8211; <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqlcheck.html" target="_blank">check it out in the MySQL Manual</a>.</li>
</ul>
<p>From the OS command prompt, issue this:</p>
<pre class="wp-code-highlight prettyprint">mysqlcheck -p -A --auto-repair</pre>
<p>This can take some time, but it will check and repair every table in every database you have. You can even perform this on a live server without taking it offline, how cool is that.</p>
<p>Once done, start your Slave again, give it some time to catch up and will hopefully resume its replication duties.</p>
<h3>Last Resort</h3>
<p>If none of the above works for you, then you can really only do one thing: lock your master again, take a new snapshot and re-import it to the Slave.</p>
<h3>Further Reading</h3>
<ul>
<li>MySQL Manual on <a href="http://dev.mysql.com/doc/refman/5.1/en/replication-problems.html">Replication Troubleshooting</a></li>
</ul>
<p><em>Have any more tips, tricks or experiences with Slaves not slaving as they should? Share them below!</em></p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/8wrOUJmwfuc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/05/mysql-replication-troubleshooting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/05/mysql-replication-troubleshooting/</feedburner:origLink></item>
		<item>
		<title>How to setup MySQL Master/Slave Replication with existing data</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/WDeaH8NZKrA/</link>
		<comments>http://wpguru.co.uk/2013/05/how-to-setup-mysql-masterslave-replication-with-existing-data/#comments</comments>
		<pubDate>Sat, 11 May 2013 15:41:35 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://wpguru.co.uk/?p=3253</guid>
		<description><![CDATA[This is a step-by-step guide on how to replicate an existing MySQL server. The server is live and contains data and needs a constant backup companion. Many tutorials focus on how to setup replication when no data is present on the system. That&#8217;s an ideal solution if you&#8217;re building a new setup, but in case [...]]]></description>
				<content:encoded><![CDATA[<p></p><p><img class="alignright  wp-image-2121" alt="mysql" src="http://wpguru.co.uk/wp-content/uploads/2012/04/mysql-300x154.gif" width="180" height="92" />This is a step-by-step guide on how to replicate an existing MySQL server. The server is live and contains data and needs a constant backup companion.</p>
<p>Many tutorials focus on how to setup replication when no data is present on the system. That&#8217;s an ideal solution if you&#8217;re building a new setup, but in case you&#8217;ve got a server that already has data present then here&#8217;s how to accomplish the this:</p>
<ol>
<li>setup your existing MySQL server (with data) as a Master</li>
<li>export all your databases and user accounts</li>
<li>create a slave and import all your data</li>
<li>start replication</li>
</ol>
<p>I&#8217;ve done this several times and always forgot to take some notes &#8211; until today. Without further ado, let&#8217;s replicate MySQL.</p>
<p><span id="more-3253"></span></p>
<h3>Prerequisites</h3>
<p>We need the following ingredients for our project:</p>
<ul>
<li>a currently running MySQL Server we want to use as a master &#8211; it&#8217;s live so we want to avoid downtime as much as we can</li>
<li>a new MySQL server which contains no data &#8211; soon to be the slave</li>
<li>root access to both servers, both for the OS and MySQL</li>
</ul>
<p>Note that any MySQL data on the slave we&#8217;re creating will be wiped out. There are ways to keep several databases unsynchronized, but this is not covered here.</p>
<p>I&#8217;m working on CentOS 6.4 here with MySQL 5.1. Whenever I issue commands to the OS the cursor prefix is &#8220;root# &#8220;, and when I&#8217;m issuing MySQL commands my cursor prefix is &#8220;mysql# &#8221; &#8211; hope this makes sense.</p>
<p>Note that if you have access to phpMyAdmin on both servers, you&#8217;ll be pleased to hear that there&#8217;s a much easier and faster way to setup replication. This article however will focus on doing all this via the command line.</p>
<h3>Setting up the Master</h3>
<p>Our current server needs to write a log of everything he&#8217;s doing from now on. This log is read later by the slave and contains a collection of statements of what has been executed by the master. Therefore the slave just remembers the position of where he last read the log, and from then onwards just does what the master does. Hence the slave ends up being in sync.</p>
<p>Login to your Master Server as root and edit the MySQL configuration file called <em><strong>/etc/my.cnf</strong></em>.</p>
<p>We need to add the following statements to give our master an ID and setup logging:</p>
<pre class="wp-code-highlight prettyprint">[mysqld]
log-bin = mysql-bin
server-id = 1</pre>
<p>Save your file and restart MySQL using</p>
<pre class="wp-code-highlight prettyprint">service mysqld restart</pre>
<p>To check that your server is logging things, head over to</p>
<pre class="wp-code-highlight prettyprint">/var/lib/mysql</pre>
<p>and see if a file by the name of <em>mysql-bin.000001</em> has been created. MySQL will write these files in sizes of up to 1GB, then start the next one. Hence it&#8217;s worth cleaning out those logs from time to time.</p>
<p>You can also check which file is currently being used by checking <em>mysql-bin.index</em> which contains a list of all log files that have been used over time.</p>
<p>Note that you may find the following statements in your configuration file:</p>
<pre class="wp-code-highlight prettyprint">skip-networking
bind-address = 127.0.0.1</pre>
<p>These need to be deleted or commented out for replication to work properly. Add a # (hash) in front of each line to do this. If they&#8217;re already commented out or not even present &#8211; even better.</p>
<h3>Getting the Master Coordinates</h3>
<p>Before we continue, we need to know where the master&#8217;s last statement was written in the log. We also need to make sure nobody is writing anything to the master while we look at this.</p>
<p>To do this, login to MySQL from a different session and issue the following command:</p>
<pre class="wp-code-highlight prettyprint">mysql# flush tables with read lock;</pre>
<p>Just so that we&#8217;re on the same page here: you now have TWO SSH sessions open, one still connected to your physical server&#8217;s OS, and another which shows your MySQL prompt.</p>
<p>Thanks to the above command, database writes cannot be committed to disk for now. Notice that MySQL still works fine and all writes are committed to memory &#8211; so there&#8217;s no downtime. We like!</p>
<p>Let&#8217;s see where the master&#8217;s last log entry was:</p>
<pre class="wp-code-highlight prettyprint">mysql# show master status;</pre>
<p>You&#8217;ll see something like this:</p>
<pre class="wp-code-highlight prettyprint">+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000037 |    14462 |              |                  | 
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)</pre>
<p>My server has been logging for some time, hence the .000037 at the end of the log fie. Make a note of these coordinates. If all goes well you won&#8217;t need them &#8211; but if you run into trouble, these will come in handy.</p>
<h3>Backing up the Master</h3>
<p>With the lock still in place, let&#8217;s go back to the first SSH session and dump all databases. Issue the following to create a dump of everything MySQL currently knows:</p>
<p><code>
<pre class="wp-code-highlight prettyprint">root# mysqldump --all-databases --user=root --password --master-data &gt; everything.sql</pre>
<p></code></p>
<p>Depending on how much data you have and how fast your server is, this can take some time&#8230; in which you&#8217;ll get no feedback whatsoever. Sit tight and grab a coffee.</p>
<p>This command will create a file called everything.sql which can be several gigabytes in size. Since we need to copy it later, let&#8217;s ZIP it up to make it smaller:</p>
<pre class="wp-code-highlight prettyprint">root# zip -r everything.zip everything.sql</pre>
<p>That should bring it down by about 80% of its previous size. Feel free to use another compression utility, or leave this step out if you feel the file is small enough for your taste.</p>
<p>If you&#8217;re an avid Linux command line user you can probably pipe the output of the mysqldump into zip or gunzip, but sadly this knowledge eludes me. Besides, I&#8217;m a big believer in smaller, more readable steps.</p>
<p>Now that we have everything from the Master, go back to the MySQL session and unlock the tables so writes can be committed to disk again:</p>
<pre class="wp-code-highlight prettyprint">mysql# unlock tables;</pre>
<p>Now the Master will start writing to disk again. You can verify this by issuing the &#8220;show master status&#8221; command again, and you should see that it&#8217;s at a different position now. Is this exciting or what?</p>
<h3>Creating a Replication User</h3>
<p>It is customary to use a dedicated MySQL user to read replication statements from the Master. All this user needs is the &#8220;replication slave&#8221; privilege. Let&#8217;s do this while we&#8217;re in this session:</p>
<p>I&#8217;ll name mine &#8220;replicator&#8221; and give it a good password. Since I may want to replicate my data to different slaves, I&#8217;ll also specify that any host can do this. To make this more secure you can specify a single host if you like.</p>
<p>Still on the MySQL prompt, the following command should take care of this:</p>
<pre class="wp-code-highlight prettyprint">
mysql# GRANT REPLICATION SLAVE ON * . * TO &#039;replicator&#039;@&#039;%&#039;
IDENTIFIED BY &#039;***&#039; WITH MAX_QUERIES_PER_HOUR 0
MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0
MAX_USER_CONNECTIONS 0 ;
</pre>
<p>This is a long command and for readability I&#8217;ve split it across 4 lines here. Replace &#8216;***&#8217; with your actual password. If you don&#8217;t like creating users on the MySQL prompt you can also use phpMyAdmin or Sequel Pro for this (if you have access to either).</p>
<p>You can now quit both sessions; we&#8217;re done with the master.</p>
<h3>Telling your Slave that he&#8217;s a Slave</h3>
<p>Just like we configured the Master, we also need to configure the slave. Open a new SSH session and edit /etc/my.cnf, then give your slave a unique ID:</p>
<pre class="wp-code-highlight prettyprint">[mysqld]
server-id = 2</pre>
<p>It doesn&#8217;t have to be just 1 or 2, you can go crazy and use a 10 digit number if you like. Just make sure the master and slave to not have the same ID. Just as before, restart MySQL on the Slave for the change to take effect:</p>
<pre class="wp-code-highlight prettyprint">root# service mysqld restart</pre>
<h3>Importing your data on the Slave</h3>
<p>The (potentially zipped) snapshot we&#8217;ve created on the Master needs to be copied over to our slave. I like using rsync for this, but scp or even FTP will do just fine. Use whatever you&#8217;re comfortable with, as long as the file ends up on your Slave machine.</p>
<p>For example, to copy everything.sql to my slave in its current directory I can issue this on the slave:</p>
<pre class="wp-code-highlight prettyprint">root# rsync -av root@master:/everything.sql .</pre>
<p>But as I said, use whatever you know best. We&#8217;ll assume that everything.sql has made it onto your slave, and that we&#8217;re in the directory where the file currently resides. We&#8217;ll also assume that you&#8217;ve un-zipped it so we end up with everything.sql.</p>
<p>We can now import the file, wiping out all existing databases on the slave. This shouldn&#8217;t be a problem if it&#8217;s a new machine that&#8217;s built for the purpose of being a slave, but if you have any data you may want to keep, this is the time to export it.</p>
<p>Issue the following command:</p>
<pre class="wp-code-highlight prettyprint">root# mysql -p &lt; everything.sql</pre>
<p>This will read in all your databases and user accounts, line by line, from the backup file. Since writes take longer than reads this can take some time again &#8211; time in which you will get no feedback whatsoever (again). I guess it&#8217;s time for another coffee/meal/movie/trip to New York.</p>
<p>A note on user accounts: each database has its own directory in /var/lib/mysql &#8211; including a database called &#8220;mysql&#8221;. This is MySQL&#8217;s own database in which it stores users and their privileges. Hence, when you import all your previous databases into the slave, you&#8217;ll automatically copy all user accounts from the master too.</p>
<p>At the same time, all information about your slave&#8217;s user accounts prior to the import will be eliminated. Therefore your previous MySQL root password for your Slave will no longer work &#8211; as it&#8217;s been replaced with that of the master.</p>
<p>When the command has finished (without any feedback if all went well) you can verify that it&#8217;s done a good job: login to MySQL with the Master&#8217;s root credentials:</p>
<pre class="wp-code-highlight prettyprint">root# mysql -u root -p</pre>
<p>Then have a look at all your server&#8217;s handy work:</p>
<pre class="wp-code-highlight prettyprint">mysql# show databases;</pre>
<p>You should see a list of all your Master&#8217;s databases. Neat, huh?</p>
<h3>Starting the Replication Station</h3>
<p>With the Master and Slave now more or less in sync, we need to make sure the Slave picks up where the Master&#8217;s last statement was. Before we go ahead, restart your MySQL Slave &#8211; trust me, this will avoid syncing issues:</p>
<pre class="wp-code-highlight prettyprint">root# service mysqld restart</pre>
<p>Remember when we dumped all our databases, we used a switch called &#8220;&#8211;master-data&#8221;? This is something that will automatically set the log coordinates on the Slave to where the Master left off writing statements. There&#8217;s no need to give our Slave this data again. Keep in mind that for troubleshooting purposes you can set those manually if you wish.</p>
<p>So all we have to do now is tell the Slave who the Master is and start it. Still on the MySQL prompt, issue the following:</p>
<pre class="wp-code-highlight prettyprint">mysql# change master to
-&gt; MASTER_HOST=&#039;masterip-or-domain&#039;,
-&gt; MASTER_USER=&#039;replicator&#039;,
-&gt; MASTER_PASSWORD=&#039;slavepassword&#039;;

mysql# start slave;</pre>
<p>With a bit of luck, this will start your Slave, which will in turn add everything that&#8217;s happened on the Master since you took the snapshot. If all went well, this is the end of your setup. Go celebrate!</p>
<p><em>Quick notes about the above statement:</em></p>
<p>You can hit return at any time on the MySQL prompt, in which case a &#8220;->&#8221; is displayed so you can add more. Only when you enter a semicolon will your statement be executed. So don&#8217;t add the &#8220;-&gt;&#8221;, MySQL will do this when you hit enter.</p>
<p>CaSe sEnsiTiviTY doesn&#8217;t matter to MySQL: &#8220;MASTER_PASSWORD&#8221; is the same as &#8220;master_password&#8221;.</p>
<p>You can add the following if you wish &#8211; you see this in many tutorials:</p>
<pre class="wp-code-highlight prettyprint">-&gt; MASTER_LOG_FILE = &#039;mysql-bin.000037&#039;,
-&gt; MASTER_LOG_POS = 14462;</pre>
<p>This is necessary if you take a mysqldump without the &#8220;&#8211;master-data&#8221; option, or if you want to point the Slave manually. If you set &#8220;&#8211;master-data&#8221;, then these two coordinates will be added automatically upon import.</p>
<h3>Verify that Replication is working</h3>
<p>I don&#8217;t like leaving things to chance and need &#8220;proof&#8221; that everything is working as intended. The simplest way to test your replication setup is by adding a new database on the master, then check if it exists on your slave.</p>
<p>You can do this via the command line, phpMyAdmin, Sequel Pro &#8211; or any other utility. Let&#8217;s create two MySQL sessions, one on the Master and one on the Slave. On both, issue the following:</p>
<pre class="wp-code-highlight prettyprint">mysql# show databases;</pre>
<p>This shows you all databases &#8211; hopefully an identical list on both servers. Now create a new database on the Master:</p>
<pre class="wp-code-highlight prettyprint">mysql# create database zzz;</pre>
<p>List your databases again and you should see &#8220;zzz&#8221; on either server. You can create as many as you like &#8211; it&#8217;s magic seeing them come to life almost instantly on your Slave. Everything works this way: tables, rows, users all change in a flash.</p>
<p>If your test databases only show up on the Master, then you have a problem (see below). Remember that if you&#8217;ve only just started the Slave, he may have some catching up to do &#8211; so give it a few minutes, as he may still be working through earlier statements from the Master.</p>
<p>When you&#8217;ve finished testing, delete those test databases databases with</p>
<pre class="wp-code-highlight prettyprint">mysql# drop database zzz;</pre>
<h3>Replication Troubleshooting</h3>
<p>You&#8217;d think once setup replication you can forget about it &#8211; but sadly that&#8217;s not the case. MySQL Replication can be extremely unreliable which is why you need to check from time to time that your Slave is still up to date.</p>
<p>This is an extensive topic, which is why I&#8217;ve decided to break this segment into <a href="wpguru.co.uk/2013/05/mysql-replication-troubleshooting">this separate article</a>.</p>
<h3>Beyond the Master/Slave Setup</h3>
<p>You can do all kinds of crazy things with MySQL Replication: if you&#8217;ve setup one Slave, you can setup several others. They&#8217;d all replicate the same data &#8211; which is extremely useful for very busy services which usually do more read queries than write queries.</p>
<p>In addition, you have constant access to &#8220;test data&#8221; and never have to take your live server down. You can swap a Slave out for a Master, or rebuild a Standby-Master from a Slave.</p>
<p>Apart from Master/Slave &#8211; imagine more than one Master: in case one breaks down you can still write to another.</p>
<p>A Master could also be a Slave to another Master, which in turn could be the Slave to the first Master. Or you could have several Masters which are also Slaves to the previous one. Circular Replication is one such setup. In theory it&#8217;s great, but imagine what happens when something goes wrong &#8211; and all Masters are out of sync&#8230; it&#8217;s fun, trust me &#8211; I&#8217;ve been there.</p>
<p>In a nutshell: go forth, dream and experiment!</p>
<h3>Further Reading</h3>
<ul>
<li>MySQL 5.1 Reference Manual: <a href="http://dev.mysql.com/doc/refman/5.1/en/replication.html">Replication Section</a></li>
<li>Rackspace KB Article on <a href="http://www.rackspace.com/knowledge_center/article/mysql-replication-masterslave">Replication</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/WDeaH8NZKrA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/05/how-to-setup-mysql-masterslave-replication-with-existing-data/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/05/how-to-setup-mysql-masterslave-replication-with-existing-data/</feedburner:origLink></item>
		<item>
		<title>How to install CentOS 6 on a Samsung NC10</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/Q07dm8LD8PY/</link>
		<comments>http://wpguru.co.uk/2013/05/centos-nc10/#comments</comments>
		<pubDate>Thu, 09 May 2013 05:28:06 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[nc10]]></category>
		<category><![CDATA[netbook]]></category>
		<category><![CDATA[samsung]]></category>

		<guid isPermaLink="false">http://wpguru.co.uk/?p=3238</guid>
		<description><![CDATA[Today was a rather exciting day for me: I&#8217;ve successfully turned my aging Samsung NC10 Netbook into an internal server in our office. I bought the little guy in 2009 and he&#8217;s been my trusty companion on many jobs before I got an iPad. He still works fine, even though Windows XP was getting weird [...]]]></description>
				<content:encoded><![CDATA[<p></p><p><img class="alignright  wp-image-3240" alt="NC10" src="http://wpguru.co.uk/wp-content/uploads/2013/05/NC10-269x300.png" width="188" height="210" />Today was a rather exciting day for me: I&#8217;ve successfully turned my aging Samsung NC10 Netbook into an internal server in our office.</p>
<p>I bought the little guy in 2009 and he&#8217;s been my trusty companion on many jobs before I got an iPad. He still works fine, even though Windows XP was getting weird of late &#8211; and admittedly I hadn&#8217;t even turned him on in over 8 months.</p>
<p>Now my trusty pal is running CentOS 6.4 while sitting quietly in a corner next to the modem, serving as an internal Linux server. This is great for testing and automated backups &#8211; and in the same spirit as playing with a Raspberry Pi (in a much neater battery powered package).</p>
<p>Refreshing the NC10 wasn&#8217;t a picnic though, and some of the steps are rather involved. Here are my notes, in case I either have to do it again or you want to follow along.</p>
<p><span id="more-3238"></span></p>
<h3>Prerequisites</h3>
<p>We need the following ingredients, apart from coffee and sandwiches:</p>
<ul>
<li>1x Samsung NC10 &#8211; working order (all data will be wiped, this is the time to make a backup of anything you want to keep)</li>
<li>1x USB Stick, 1GB or greater</li>
<li>Ethernet Cable to your router and internet connection</li>
<li>a couple of hours uninterrupted time</li>
<li>patience</li>
</ul>
<p>&nbsp;</p>
<h3>Getting the Software</h3>
<p><img class="alignright  wp-image-555" alt="CentOS" src="http://wpguru.co.uk/wp-content/uploads/2010/08/CentOS-300x114.jpg" width="180" height="68" />For this adventure we need the correct version of CentOS. The Intel Atom processor in the NC10 does not support 64bit so we&#8217;ll use the 32bit version of CentOS &#8211; the latest version at the time of writing in May 2013 is CentOS 6.4.</p>
<p>You won&#8217;t be able to download the software from The CentOS project directly &#8211; instead check out the <a href="http://www.centos.org/modules/tinycontent/index.php?id=30" target="_blank">list of public mirrors</a> and pick one in your area. I&#8217;m in Miami Beach so I chose one from the friendly guys over at <a href="http://www.mojohost.com/" target="_blank">Mojohost</a> not far away from me.</p>
<p>You can download the files via HTTP or FTP, both will work in your favorite web browser. FTP will also work in FileZilla: just copy the relevant address into the Quick Connect host box and start downloading.</p>
<p>Once connected navigate to the following path:</p>
<pre class="wp-code-highlight prettyprint">/centos/6.4/isos</pre>
<p>In here you&#8217;ll find two directories: x86_64 and i386 &#8211; these are the 64bit and 32bit versions respectively. Since we need the 32bit version we&#8217;ll choose the latter. These are the main files you may find useful, depending on how you&#8217;d like to install CentOS:</p>
<ul>
<li><em>CentOS-6.4-i386-bin-DVD1.iso</em> and <em>DVD2.iso</em> &#8211; full DVD images, a total of about 7GB</li>
<li><em>CentOS-6.4-i386-netinstall.iso</em> &#8211; 200MB to download, but requires a working and configured internet connection during installation</li>
<li><em>CentOS-6.4-i386-minimal.iso</em> &#8211; slightly bigger with 315MB, but gets you a running system with a rather small file and no need for an internet connection</li>
</ul>
<p>All I want from my NC10 is to be a remote server, so I don&#8217;t need a graphical user interface and hence I chose the latter. If you want the full GNOME version with all desktop bells and whistles, download either the DVD images or choose the netinstall option.</p>
<p>&nbsp;</p>
<h3>Turning ISO Images into Bootable USB Drives</h3>
<p>Burning those ISO images onto DVDs or CDs isn&#8217;t a problem &#8211; but creating bootable non-optical media from them isn&#8217;t that easy (nor obvious): The trusty Disk Utility on Mac doesn&#8217;t work, the <a href="http://wiki.centos.org/HowTos/InstallFromUSBkey" target="_blank">manual method</a> described by CentOS is not for the faint hearted, and the &#8220;easy solution&#8221; mentioned in the same article requires a working local CentOS installation.</p>
<p>Neither option was for me, so I moved on. Inevitably I stumbled upon the <a href="http://unetbootin.sourceforge.net/" target="_blank">Unetbootin utility</a> which promises to download CentOS and burn an SD card or USB stick in one fair swoop. Available for Mac, Windows and Linux. Sounds great!</p>
<p>Sadly though the Mac version doesn&#8217;t seem to do anything on Mountain Lion, so this wasn&#8217;t for me either &#8211; especially considering that I had already downloaded the file I needed. There had to be an easier option &#8211; and thankfully there was:</p>
<p><a href="http://iso2usb.sourceforge.net/" target="_blank"><img class="alignright size-full wp-image-3239" alt="Screen Shot 2013-05-08 at 23.39.43" src="http://wpguru.co.uk/wp-content/uploads/2013/05/Screen-Shot-2013-05-08-at-23.39.43.png" width="201" height="147" />ISO2USB</a> is a small utility by Alex Agranov and does exactly what it says on the box: write an ISO image onto an SD card or USB stick. It&#8217;s only available for Windows though, but since my NC10 still had that in more or less working condition I used it &#8211; and it worked very well.</p>
<p>I highly recommend ISO2USB, <a href="http://iso2usb.sourceforge.net/" target="_blank">check it out at Sourceforge</a>. If you don&#8217;t have a working version of Windows to hand, you may think of a virtual instance running on Parallels Desktop. Sadly however my Windows 7 version did not see the attached USB devices so I couldn&#8217;t use it for this purpose &#8211; but I admit that I didn&#8217;t try very hard to set those up. Perhaps you have more luck me.</p>
<h3></h3>
<h3>NC10: Booting into something other than Windows</h3>
<p>First of all:<strong> you cannot boot your NC10 from an SD Card,</strong> not without a BIOS hack at least. Let&#8217;s not go down that route, we&#8217;re busy people. Instead burn the above ISO image onto a USB stick you probably find lying around and pop it into your NC10.</p>
<p>Hold down F2 while switching the NC10 on to get into the BIOS. There&#8217;s not much to do here, even though I thought I could switch the boot order to make it recognize the USB stick. But that&#8217;s not how you do it.</p>
<p>Instead, <strong>hold down F9</strong> while switching on your netbook and hey presto &#8211; you&#8217;ll boot from any USB port. If no stick is attached all you&#8217;ll hear is a loud squealing noise for about 2 seconds, followed by the NC10 powering down.</p>
<p>Upon success, you&#8217;re greeted by the CentOS installer screen. I chose the first option and the installation went ahead just fine.</p>
<h3></h3>
<h3>Installing CentOS</h3>
<p><img class="alignright size-thumbnail wp-image-2938" alt="terminal" src="http://wpguru.co.uk/wp-content/uploads/2013/02/terminal-150x150.png" width="150" height="150" />It&#8217;s very straightforward, but there were two points that I thought needed a special mention: setting up your network connection and partitioning your hard drives. Let&#8217;s start with the latter.</p>
<p>Linux is a bit different when it comes to &#8220;having space&#8221; versus &#8220;creating a partition&#8221;. To us mortals a &#8220;partition&#8221; is just a chunk of space which ultimately turns into a drive letter. How and why we don&#8217;t really care about. As long as we can say something like &#8220;use EVERYTHING on the drive and turn it into the C Drive, go ahead and do it&#8221;.</p>
<p>The NC10&#8242;s 160GB hard drives comes pre-partitioned into two equally sized chunks, drive C: and D: &#8211; but I didn&#8217;t like those and wanted all my space consolidated into one chunk, or as close to that as possible.</p>
<p>See, Linux needs a &#8220;boot&#8221; partition and a &#8220;data&#8221; partition. Each partition can then me divided into &#8220;logical volumes&#8221; which in turn can be &#8220;mounted&#8221; and appear as standard folders. This is great for extending the file system across multiple drives and devices, but it makes it a bit trickier to setup.</p>
<p>I chose the option to &#8220;Use all available space&#8221; in the partitioning section, and as a result my file system now looks like this:</p>
<pre class="wp-code-highlight prettyprint">[root@nc10 home]# fdisk -l</pre>
<pre class="wp-code-highlight prettyprint">   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       19458   155777024   8e  Linux LVM

Disk /dev/mapper/vg_nc10-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_nc10-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_nc10-lv_home: 103.7 GB, 103712555008 bytes
255 heads, 63 sectors/track, 12608 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000</pre>
<p>This tells us that I have indeed two separate drives (/dev/sda1 and /dev/sda2), one being a very small boot drive, and the other being a larger data drive. But then we see three various volumes which have been created:</p>
<p>root, swap and home &#8211; all with varying sizes.</p>
<p>After the installation all this space is mounted into the following places, as shown by the df- h command:</p>
<pre class="wp-code-highlight prettyprint">[root@nc10 home]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_nc10-lv_root    50G  862M   46G   2% /
tmpfs                                                  498M     0  498M   0% /dev/shm
/dev/sda1                                          485M   49M  412M  11% /boot
/dev/mapper/vg_nc10-lv_home  96G  188M   91G   1% /home</pre>
<p>For us humans, we&#8217;ll end up with the following folders:</p>
<ul>
<li>/ (root directory, 50G available)</li>
<li>/home (91G available)</li>
<li>and a swap drive, currently 498M but unavailable for us to write onto</li>
</ul>
<p>Linux does this so that all the operational things can be kept from data storage (in /home) &#8211; therefore if you accidentally fill up your server you don&#8217;t compromise running the OS.</p>
<p>If you feel that some of the 50G is better spent in the /home directory you can change this later &#8211; but for now this is the default configuration that CentOS sees as &#8220;use everything&#8221;.</p>
<div id="attachment_3249" class="wp-caption aligncenter" style="width: 490px"><img class="size-large wp-image-3249" alt="It works: CentOS 6.4 on Samsung NC10" src="http://wpguru.co.uk/wp-content/uploads/2013/05/NC10-screen-480x459.png" width="480" height="459" /><p class="wp-caption-text">It works: CentOS 6.4 on Samsung NC10</p></div>
<h3>Configuring the Network</h3>
<p>On the screen that allows you to name your computer (the default is &#8220;localhost.localdomain&#8221;, but I&#8217;ve called mine &#8220;nc10&#8243;) there&#8217;s a small button which is easy to overlook the first time round: it&#8217;s called &#8220;Configure Network&#8221;.</p>
<p><em><strong>Turns out it&#8217;s VITAL that you press it!</strong></em></p>
<p>In it you&#8217;ll be able to configure ETH0 and WLAN0, two default network connections. If you don&#8217;t do this, then you&#8217;ll end up with no internet connection once the installation is complete. We&#8217;ll leave WLAN0 for now because we haven&#8217;t got the right driver yet.</p>
<p>Click ETH0 and tick the box that says &#8220;Connect Automatically&#8221;. Make sure that at this point an Ethernet cable from your router is connected to the NC10 and watch those little lights spring into action.</p>
<p>The rest of the installation runs smoothly until you&#8217;re asked to reboot the system.</p>
<h3>Loggin in locally for the first time</h3>
<p>All the NC10 is going to display after its reboot is a local console screen, just like we love it from countless SSH sessions. This is great! Login as root and say hello to your new CentOS installation!</p>
<p>To test that everything is working, type something nice like</p>
<pre class="wp-code-highlight prettyprint">cat /etc/*release</pre>
<p>This should bring up your current CentOS version. Next let&#8217;s check out network connectivity:</p>
<pre class="wp-code-highlight prettyprint">yum update</pre>
<p>This should take a moment and come back with a list of packages that need to be updated. Go ahead and do this if you have a moment. If this command comes back very quickly with an error message, then it&#8217;s likely that your network connection isn&#8217;t working properly. Let&#8217;s hope that&#8217;s not the case though <img src='http://wpguru.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<h3>Loggin in remotely</h3>
<p>Before you start to talk to your NC10 from another device via SSH we need to know it&#8217;s IP address on the network. By default this is configured dynamically, so every time you turn off your NC10 it may be a different one &#8211; unless you tell your network configuration otherwise.</p>
<p>Still logged on locally, type in the following command:</p>
<pre class="wp-code-highlight prettyprint">/sbin/ifconfig</pre>
<p>This will come back with a list similar to this one:</p>
<pre class="wp-code-highlight prettyprint">eth0      Link encap:Ethernet  HWaddr 00:13:77:D4:DA:D0  
          inet addr:192.168.1.234  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: 2602:306:cd83:aad0:213:77ff:fed4:dad0/64 Scope:Global
          inet6 addr: fe80::213:77ff:fed4:dad0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:136409 errors:0 dropped:0 overruns:0 frame:0
          TX packets:36952 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:91070263 (86.8 MiB)  TX bytes:3285128 (3.1 MiB)
          Interrupt:18 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1008 (1008.0 b)  TX bytes:1008 (1008.0 b)</pre>
<p>&nbsp;</p>
<p>Notice the second line that reads inet addr, followed by your IP address.</p>
<p>Go grab any device on the same network and connect with your favorite SSH client (Terminal on Mac, PuTTY on Windows, or Prompt on your iPad/iPhone) using the following command:</p>
<pre class="wp-code-highlight prettyprint">ssh root@192.168.1.234</pre>
<p>obviously using your own IP address and password when prompted. Now you can close the lid on the NC10, supply it with a power source and start treating it as  a proper remote server.</p>
<h3>Lovely &#8211; it&#8217;s working. Now what do I do?</h3>
<p>Here are some of the cool things you can do with your new NC10 Server:</p>
<ul>
<li>install MySQL and run your own database server (as <a href="http://wpguru.co.uk/2012/04/how-to-install-mysql-on-centos-2/">discussed here</a>)</li>
<li>import some databases and use your NC10 Server as a local backup to a remote server</li>
<li>install Apache and run local instances of WordPress</li>
<li>setup a cron job or two and backup files regularly</li>
<li>install Plesk and do some testing</li>
<li>repartition the hard drives</li>
</ul>
<p>The fun never stops when you have your own free server within arm&#8217;s reach.</p>
<p>Have fun!</p>
<p>&nbsp;</p>
<h3>Further Reading</h3>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Samsung_NC10" target="_blank">Samsung NC10 on Wikipedia</a></li>
<li>List of <a href="http://www.centos.org/modules/tinycontent/index.php?id=30" target="_blank">CentOS Mirrors</a></li>
<li><a href="http://iso2usb.sourceforge.net/" target="_blank">ISO2USB Homepage</a> on Sourceforge</li>
</ul>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/Q07dm8LD8PY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/05/centos-nc10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/05/centos-nc10/</feedburner:origLink></item>
		<item>
		<title>How to switch SketchBook Pro 6 into Full Screen Mode</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/ea0gCG5hPW4/</link>
		<comments>http://wpguru.co.uk/2013/05/how-to-switch-sketchbook-pro-6-into-full-screen-mode/#comments</comments>
		<pubDate>Wed, 01 May 2013 04:05:33 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Autodesk]]></category>
		<category><![CDATA[SketchBook Pro]]></category>

		<guid isPermaLink="false">http://wpguru.co.uk/?p=3217</guid>
		<description><![CDATA[The Mac version of Autodesk&#8217;s SketchBook Pro 6 works well on small screen &#8211; but since real estate is limited, there is a way to switch the app to Full Screen Mode. Rather than the double-arrow in the top right corner though, you&#8217;ll have to use the shortcut OPTION+CTRL+J Don&#8217;t ask me why, it&#8217;s not [...]]]></description>
				<content:encoded><![CDATA[<p></p><p><img class="alignright  wp-image-3227" alt="SketchBookPro-Logo" src="http://wpguru.co.uk/wp-content/uploads/2013/05/SketchBookPro-Logo-300x155.jpg" width="210" height="109" />The Mac version of Autodesk&#8217;s <a href="http://www.autodesk.com/products/sketchbook-pro/overview" target="_blank">SketchBook Pro 6</a> works well on small screen &#8211; but since real estate is limited, there is a way to switch the app to Full Screen Mode.</p>
<p>Rather than the double-arrow in the top right corner though, you&#8217;ll have to use the shortcut</p>
<p><strong>OPTION+CTRL+J</strong></p>
<p>Don&#8217;t ask me why, it&#8217;s not very well documented for such an intuitive app. And since I keep forgetting how to do this, here it is in writing.</p>
<p>Thanks to Eric from Autodesk for this tip (<a href="https://getsatisfaction.com/sketchbook/topics/will_sketchbook_pro_take_advantage_of_fullscreen_mode_on_mac_osx" target="_blank">discussion</a>)</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/ea0gCG5hPW4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/05/how-to-switch-sketchbook-pro-6-into-full-screen-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/05/how-to-switch-sketchbook-pro-6-into-full-screen-mode/</feedburner:origLink></item>
		<item>
		<title>How to create an NSDate object</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/GXQFK6tzVtE/</link>
		<comments>http://wpguru.co.uk/2013/04/how-to-create-an-nsdate-object/#comments</comments>
		<pubDate>Mon, 29 Apr 2013 15:34:41 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSDate]]></category>
		<category><![CDATA[NSDateFormatter]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-create-an-nsdate-object/</guid>
		<description><![CDATA[The easiest way to create an NSDate object is to create &#8220;right now&#8221; with our convenience method date: NSDate *myDate = [NSDate date]; But if you want to create a date object with a date such as your birthday it gets a little bit trickier, and &#8211; more importantly &#8211; much less obvious. To do [...]]]></description>
				<content:encoded><![CDATA[<p>The easiest way to create an NSDate object is to create &#8220;right now&#8221; with our convenience method date:</p>
<pre class="wp-code-highlight prettyprint">
NSDate *myDate = [NSDate date];
</pre>
<p>But if you want to create a date object with a date such as your birthday it gets a little bit trickier, and &#8211; more importantly &#8211; much less obvious. </p>
<p>To do this, we need to create an NSDateFormatter, tell the formatter how to expect the date, and then use its convenience method dateFromString to create the date:</p>
<pre class="wp-code-highlight prettyprint">
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
formatter.dateFormat = @&quot;YYYY-MM-DD&quot;;
NSDate *myDate = [formatter dateFromString:@&quot;2012-12-12&quot;];
</pre>
<p>Notice that I tell the date formatter to expect the date as YYYY-MM-DD. I could also have told it to expect it as YYMMDD and then pass @&#8221;12-12-12&#8243; in the dateFromString method. </p>
<p>Whichever way you do it, the date format must match your string, otherwise the method returns null.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/GXQFK6tzVtE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/04/how-to-create-an-nsdate-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/04/how-to-create-an-nsdate-object/</feedburner:origLink></item>
		<item>
		<title>How to display the full month from an NSDate (such as “February”)</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/3xS6Dg4UA-U/</link>
		<comments>http://wpguru.co.uk/2013/04/how-to-display-the-full-month-from-an-nsdate-such-as-february/#comments</comments>
		<pubDate>Mon, 29 Apr 2013 15:15:14 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSDate]]></category>
		<category><![CDATA[NSDateFormatter]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-display-the-full-month-from-an-nsdate-like-february/</guid>
		<description><![CDATA[There was me thinking I&#8217;d have to whip out NSDateComponents and NSCalendar &#8211; but my mind works too complicated at times. All we need to do this is our good friend the NSDateFormatter and the Unicode Date Format MMMM &#8211; let&#8217;s check it out: // create today's date NSDate *myDate = [NSDate date]; // create [...]]]></description>
				<content:encoded><![CDATA[<p>There was me thinking I&#8217;d have to whip out NSDateComponents and NSCalendar &#8211; but my mind works too complicated at times. </p>
<p>All we need to do this is our good friend the NSDateFormatter and the Unicode Date Format MMMM &#8211; let&#8217;s check it out:</p>
<pre class="wp-code-highlight prettyprint">
// create today&#039;s date
NSDate *myDate = [NSDate date];
// create a date formatter and set its format
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
formatter.dateFormat = @&quot;MMMM&quot;;
        
NSLog(@&quot;The current month is %@&quot;, [formatter stringFromDate:myDate]);
</pre>
<p>The MMMM tells the date formatter to display the full month, no matter how many letters it has. You can also use:</p>
<ul>
<li>M for the month number (1 for January or 12 for December)</li>
<li>MM for the two-digit month number (01 for January)</li>
<li>MMM for the abbreviated month number (Jan for January)</li>
<li>MMMM for the full month number (such as January)</li>
<li>MMMMM for just the first letter (J for January&#8230; not sure who would need this though)</li>
</ul>
<p>The Unicode Date Format can do amazing things with all aspects of times and dates &#8211; check out the complete compendium here:</p>
<p><a href="http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns" rel="nofollow">http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns</a></p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/3xS6Dg4UA-U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/04/how-to-display-the-full-month-from-an-nsdate-such-as-february/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/04/how-to-display-the-full-month-from-an-nsdate-such-as-february/</feedburner:origLink></item>
		<item>
		<title>How to create Linkshare Affiliate Links to iTunes Products</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/JT779s_ZZr4/</link>
		<comments>http://wpguru.co.uk/2013/04/how-to-create-linkshare-affiliate-links-to-itunes-products/#comments</comments>
		<pubDate>Sat, 27 Apr 2013 18:16:30 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-create-linkshare-affiliate-links-to-itunes-products/</guid>
		<description><![CDATA[One of the worst ever interfaces i have ever come across is that of Rakuten LinkShare. Even before they&#8217;ve been bought by Japanese giant Rakuten it was bad, and it hasn&#8217;t been improved since I&#8217;ve signed up with them in 2008. Lucky for us we don&#8217;t have to use their interface to get links to [...]]]></description>
				<content:encoded><![CDATA[<p>One of the worst ever interfaces i have ever come across is that of Rakuten LinkShare. Even before they&#8217;ve been bought by Japanese giant Rakuten it was bad, and it hasn&#8217;t been improved since I&#8217;ve signed up with them in 2008.</p>
<p>Lucky for us we don&#8217;t have to use their interface to get links to iTunes Products &#8211; we can use the standard good looking and well working iTunes Link Maker. All we need is go there via LinkShare, which will embed our affiliate code.</p>
<p>Here&#8217;s how to do this step by step:</p>
<p>1.) Login to LinksShare and see the awful Home Screen<br />
2.) Head over to Links &#8211; Get Links<br />
3.) Click on &#8220;US iTunes, App Store, iBookstore, and Mac App Store&#8221; (you need to be subscribed and approved for this option to become available).</p>
<p>This should get you to a screen similar to this:</p>
<p>&nbsp;</p>
<p><a href="http://pinkstone.co.uk/wp-content/uploads/2013/03/Screen-Shot-2013-04-27-at-14.09.41.png"><img class="aligncenter size-large wp-image-752" alt="Screen Shot 2013-04-27 at 14.09.41" src="http://pinkstone.co.uk/wp-content/uploads/2013/03/Screen-Shot-2013-04-27-at-14.09.41-600x367.png" width="600" height="367" /></a></p>
<p>&nbsp;</p>
<p>4.) Notice the grey button that says &#8220;Link Maker Tool&#8221;. Click that and you get to a new window and is the familiar iTunes Link Builder, as provided by Apple:</p>
<p>&nbsp;</p>
<p><a href="http://pinkstone.co.uk/wp-content/uploads/2013/04/Screen-Shot-2013-04-27-at-14.12.01.png"><img class="aligncenter size-large wp-image-755" alt="Screen Shot 2013-04-27 at 14.12.01" src="http://pinkstone.co.uk/wp-content/uploads/2013/04/Screen-Shot-2013-04-27-at-14.12.01-600x342.png" width="600" height="342" /></a></p>
<p>&nbsp;</p>
<p>Note the message that reads: &#8220;Your affiliate Network is&#8230;&#8221; &#8211; this is the confirmation that you&#8217;re building links as an affiliate. If that message isn&#8217;t there, your links are not tracked. Instead if LinkShare, this can be a different partner (TradeDoubler is another one for example).</p>
<p>Now you can enter a product and grab the link, which will already contain your affiliate ID.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/JT779s_ZZr4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/04/how-to-create-linkshare-affiliate-links-to-itunes-products/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/04/how-to-create-linkshare-affiliate-links-to-itunes-products/</feedburner:origLink></item>
		<item>
		<title>How to create a UIBarButtonItem in code and make it call a method</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/muD_Kq93tFo/</link>
		<comments>http://wpguru.co.uk/2013/04/how-to-create-a-uibarbuttonitem-in-code-and-make-it-call-a-method/#comments</comments>
		<pubDate>Sat, 27 Apr 2013 17:37:06 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[UIBarButton]]></category>
		<category><![CDATA[UINavigationBar]]></category>
		<category><![CDATA[UINavigationController]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-create-a-uibarbuttonitem-in-code-and-make-it-call-a-method/</guid>
		<description><![CDATA[Some things are really easy to do via a Storyboard &#8211; but when you want to create the same thing in code I frequently forget how to do it. Turns out it&#8217;s equally simple: this example assumes you have a View Controller which is embedded in a Navigation Controller (so it already has a UINavigationBar [...]]]></description>
				<content:encoded><![CDATA[<p>Some things are really easy to do via a Storyboard &#8211; but when you want to create the same thing in code I frequently forget how to do it. </p>
<p>Turns out it&#8217;s equally simple: this example assumes you have a View Controller which is embedded in a Navigation Controller (so it already has a UINavigationBar at the top). Here&#8217;s how you add a button to it, set the title and target, and tell it what to do when it&#8217;s pressed:</p>
<pre class="wp-code-highlight prettyprint">
- (void) viewDidLoad
{
    [super viewDidLoad];
	
    // first we create a button and set it&#039;s properties
    UIBarButtonItem *myButton = [[UIBarButtonItem alloc]init];
    myButton.action = @selector(doTheThing);
    myButton.title = @&quot;Hello&quot;;
    myButton.target = self;
    
    // then we add the button to the navigation bar
    self.navigationItem.rightBarButtonItem = myButton;
    
    
}


// method called via selector
- (void) doTheThing {
    
    NSLog(@&quot;Doing the thing&quot;);
    
}
</pre>
<p>You can set the button on the left hand site by using self.navigationItem.leftBarButtonItem</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/muD_Kq93tFo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/04/how-to-create-a-uibarbuttonitem-in-code-and-make-it-call-a-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/04/how-to-create-a-uibarbuttonitem-in-code-and-make-it-call-a-method/</feedburner:origLink></item>
		<item>
		<title>How to remove a Core Data Model Version</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/InwpSOQsLKE/</link>
		<comments>http://wpguru.co.uk/2013/04/how-to-remove-a-core-data-model-version/#comments</comments>
		<pubDate>Fri, 26 Apr 2013 20:57:41 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Core Data]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-remove-a-core-data-model-version/</guid>
		<description><![CDATA[Core Data can handle several versions of your Model. It&#8217;s easy to add a version (via Editor &#8211; Add Model Version) and set it active, but it&#8217;s not so easy to remove a version you no longer need. Thankfully there is a way to delete version files which goes a long way to declutter your [...]]]></description>
				<content:encoded><![CDATA[<p>Core Data can handle several versions of your Model. It&#8217;s easy to add a version (via Editor &#8211; Add Model Version) and set it active, but it&#8217;s not so easy to remove a version you no longer need.</p>
<p>Thankfully there is a way to delete version files which goes a long way to declutter your brain. The secret lies in the fact that the .xcdatamodeld file is actually a Package and can contain more than one file. It&#8217;s like the .app extension which isn&#8217;t just one file. I never knew this!</p>
<p>To explore, select your versioned .xcdatamodeld file, right-click it and select &#8220;Show in Finder&#8221;. Once in there right-click it again and select &#8220;Show Package Contents&#8221;. Surprise &#8211; here are all your Model Versions. Before you go on a mad deleting spree, head back to Xcode and do the following:</p>
<ol>
<li>activate a Model Version that you want to keep (by going to the top level .xcdatamodeld entry, then select it under &#8220;Versioned Core Data Model&#8221;)</li>
<li>next remove the entire file from your project (just the reference&#8230; do not move to trash)</li>
<li>head back to the Finder and delete the files inside the Package you no longer want</li>
<li>go back to Xcode and add the .xcdatamodeld file again</li>
</ol>
<p>Voila &#8211; now all your unnecessary Model Versions are gone. Perhaps in a future version of Xcode there will be an easier way to do this, but as of Xcode 4.6.2 (April 2013) there is not.</p>
<h3>Further Reading</h3>
<p>Thanks to David Avendasora for this wonderfully simple explanation on Stack Overflow: <a href="http://stackoverflow.com/questions/7708392/how-to-delete-an-old-unused-data-model-version-in-xcode-4" rel="nofollow">http://stackoverflow.com/questions/7708392/how-to-delete-an-old-unused-data-model-version-in-xcode-4</a></p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/InwpSOQsLKE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/04/how-to-remove-a-core-data-model-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/04/how-to-remove-a-core-data-model-version/</feedburner:origLink></item>
		<item>
		<title>How to create a View Controller defined in you your Storyboard programmatically</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/mwxeuuLs7BE/</link>
		<comments>http://wpguru.co.uk/2013/04/how-to-create-a-view-controller-defined-in-you-your-storyboard-programmatically/#comments</comments>
		<pubDate>Sun, 21 Apr 2013 13:20:39 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[UIViewController]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-create-a-view-controller-defined-in-you-your-storyboard-programmatically/</guid>
		<description><![CDATA[Your View Controllers are created by the Storyboard automatically depending their defined relationships in Interface Builder. Sometimes however we need to create and transition to View Controllers we&#8217;ve defined in code. For example, if you want to transition to a view as part of displaying a search result. We can do this by creating a [...]]]></description>
				<content:encoded><![CDATA[<p>Your View Controllers are created by the Storyboard automatically depending their defined relationships in Interface Builder. </p>
<p>Sometimes however we need to create and transition to View Controllers we&#8217;ve defined in code. For example, if you want to transition to a view as part of displaying a search result. </p>
<p>We can do this by creating a new UIStoryboard object and then asking it to create a View Controller defined in it. For this to work you need to give your View Controller a unique identifier using the Identity Inspector (under Identity, set a Storyboard ID).</p>
<p>This example assumes we have a Storyboard file called MainStoryboard.storyboard in which there&#8217;s a View Controller called DetailView. Here&#8217;s how we create it and push it onto a stack of Navigation Controllers:</p>
<pre class="wp-code-highlight prettyprint">
// create the Storyboard object
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@&quot;MainStoryboard&quot; bundle:nil];
DetailViewController *detailView = [storyboard instantiateViewControllerWithIdentifier:@&quot;DetailView&quot;];

// set properties you&#039;d like the detailView to have (optional)
detailView.someProperty = @&quot;This is great&quot;;

// push the new detailView onto the stack
[self.navigationController pushViewController:detailView animated:YES];
</pre>
<p>Note that you define the Storyboard without its extension. If the bundle parameter is nil (as it is here) then the compiler assumes your main bundle.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/mwxeuuLs7BE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/04/how-to-create-a-view-controller-defined-in-you-your-storyboard-programmatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/04/how-to-create-a-view-controller-defined-in-you-your-storyboard-programmatically/</feedburner:origLink></item>
		<item>
		<title>How to add a Search Display Controller to a UITableView (in code)</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/QbOIVzTbQww/</link>
		<comments>http://wpguru.co.uk/2013/04/how-to-add-a-search-display-controller-to-a-uitableview-in-code/#comments</comments>
		<pubDate>Sun, 21 Apr 2013 03:39:32 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[UISearchBar]]></category>
		<category><![CDATA[UITableView]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-add-a-search-display-controller-to-a-uitableview-in-code/</guid>
		<description><![CDATA[We&#8217;ve recently discussed how to deal with a Search Bar and Search Display Controller using Interface Builder. You can however do this in code too. This can be useful if you don&#8217;t want to make all the relevant connections in every Storyboard. This example assumes you have a Table View (self.tableView) to which you&#8217;d like [...]]]></description>
				<content:encoded><![CDATA[<p>We&#8217;ve recently discussed how to deal with a Search Bar and Search Display Controller using Interface Builder. You can however do this in code too. This can be useful if you don&#8217;t want to make all the relevant connections in every Storyboard.</p>
<p>This example assumes you have a Table View (self.tableView) to which you&#8217;d like to add a Search Bar and Search Display Controller at the top. We do this by utilising the Table View&#8217;s tableHeaderView property:</p>
<pre class="wp-code-highlight prettyprint">
// create a new Search Bar and add it to the table view
UISearchBar *searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)];
self.tableView.tableHeaderView = searchBar;
        
// we need to be the delegate so the cancel button works
searchBar.delegate = self;
        
// create the Search Display Controller with the above Search Bar
self.controller = [[UISearchDisplayController alloc]initWithSearchBar:self.searchBar contentsController:self];
self.controller.searchResultsDataSource = self;
self.controller.searchResultsDelegate = self;
</pre>
<p>Your View Controller also needs to conform to the UISearchBarDelegate Protocol for this to work properly.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/QbOIVzTbQww" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/04/how-to-add-a-search-display-controller-to-a-uitableview-in-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/04/how-to-add-a-search-display-controller-to-a-uitableview-in-code/</feedburner:origLink></item>
		<item>
		<title>How to change your User Name in WordPress</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/i9eNV1gF48I/</link>
		<comments>http://wpguru.co.uk/2013/04/how-to-change-your-user-name-in-wordpress/#comments</comments>
		<pubDate>Tue, 16 Apr 2013 02:17:02 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[Podcast]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[User Name]]></category>

		<guid isPermaLink="false">http://wpguru.co.uk/?p=3203</guid>
		<description><![CDATA[This week has seen a rather large scale attack of a bot network that specifically targets the &#8220;admin&#8221; user in WordPress installations. This means that if your site as a user called &#8220;admin&#8221; then your site is under threat of being a potential target. No matter if you&#8217;re using &#8220;admin&#8221; as an active user or [...]]]></description>
				<content:encoded><![CDATA[<p></p><p>This week has seen a rather <a href="http://www.bbc.co.uk/news/technology-22152296" target="_blank">large scale attack of a bot network</a> that specifically targets the &#8220;admin&#8221; user in WordPress installations. This means that if your site as a user called &#8220;admin&#8221; then your site is under threat of being a potential target.</p>
<p>No matter if you&#8217;re using &#8220;admin&#8221; as an active user or not: if it exists, your site is at risk. Period.</p>
<p>In this podcast I&#8217;ll show you how to change your user name. Sadly this isn&#8217;t as easy as just amending &#8220;admin&#8221; to something else; you&#8217;ll have to create a new user, then delete the &#8220;admin&#8221; user from your site. Don&#8217;t be afraid though, I&#8217;ll cover each and every step in detail and explain why this is necessary.</p>
<p>Enjoy!</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='500' height='312' src='http://www.youtube.com/embed/DLGONrzVoYY?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<h3>Further Reading</h3>
<ul>
<li><a href="http://www.bbc.co.uk/news/technology-22152296" target="_blank">BBC News Report</a></li>
<li><a href="http://ma.tt/2013/04/passwords-and-brute-force/" target="_blank">Matt&#8217;s post</a> about this problem</li>
<li>Kelly&#8217;s Step by step screenshots on <a href="http://www.digitalkonline.com/blog/change-your-wordpress-admin-username/" target="_blank">how to create a new user</a></li>
</ul>
<p>Thanks to <a href="http://baggieandlucy.com" target="_blank">Richard Bagnall</a> for bringing this to my attention <img src='http://wpguru.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/i9eNV1gF48I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/04/how-to-change-your-user-name-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://wpguru.co.uk/wp-content/uploads/podcast/207.mp4" length="150664528" type="video/mp4" />
			<itunes:keywords>User Name,WordPress</itunes:keywords>
	<itunes:subtitle>This week has seen a rather large scale attack of a bot network that specifically targets the "admin" user in WordPress installations. This means that if your site as a user called "admin" then your site is under threat of being a potential target. - </itunes:subtitle>
		<itunes:summary>This week has seen a rather large scale attack of a bot network that specifically targets the "admin" user in WordPress installations. This means that if your site as a user called "admin" then your site is under threat of being a potential target.

No matter if you're using "admin" as an active user or not: if it exists, your site is at risk. Period.

In this podcast I'll show you how to change your user name. Sadly this isn't as easy as just amending "admin" to something else; you'll have to create a new user, then delete the "admin" user from your site. Don't be afraid though, I'll cover each and every step in detail and explain why this is necessary.

Enjoy!

http://youtu.be/DLGONrzVoYY
Further Reading

	BBC News Report
	Matt's post about this problem
	Kelly's Step by step screenshots on how to create a new user

Thanks to Richard Bagnall for bringing this to my attention ;-)</itunes:summary>
		<itunes:author>Jay Versluis</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>16:03</itunes:duration>
		<rawvoice:isHD>yes</rawvoice:isHD>
		<rawvoice:poster url="http://wpguru.co.uk/wp-content/uploads/2013/04/207-Change-User-Name.001.jpg" />
	<feedburner:origLink>http://wpguru.co.uk/2013/04/how-to-change-your-user-name-in-wordpress/</feedburner:origLink></item>
		<item>
		<title>How to add a User Account on CentOS</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/LsF-NyAN7Y0/</link>
		<comments>http://wpguru.co.uk/2013/04/how-to-add-a-user-account-on-centos/#comments</comments>
		<pubDate>Sun, 14 Apr 2013 16:28:31 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[centos]]></category>

		<guid isPermaLink="false">http://wpguru.co.uk/?p=3198</guid>
		<description><![CDATA[On both CentOS and Red Hat Linux systems you can easily create new user accounts with their own home directories. Here&#8217;s how you do this from the command line. I&#8217;m assuming you&#8217;re logged in as root, and the new user we&#8217;d like to create is called &#8220;testuser&#8221;: useradd testuser Let&#8217;s give our testuser a password [...]]]></description>
				<content:encoded><![CDATA[<p></p><p><img class="alignright  wp-image-555" alt="CentOS" src="http://wpguru.co.uk/wp-content/uploads/2010/08/CentOS-300x114.jpg" width="180" height="68" />On both CentOS and Red Hat Linux systems you can easily create new user accounts with their own home directories.</p>
<p>Here&#8217;s how you do this from the command line. I&#8217;m assuming you&#8217;re logged in as root, and the new user we&#8217;d like to create is called &#8220;testuser&#8221;:</p>
<pre class="wp-code-highlight prettyprint">useradd testuser</pre>
<p>Let&#8217;s give our testuser a password so s/he can login to the system via SSH:</p>
<pre class="wp-code-highlight prettyprint">passwd testuser</pre>
<p>This will prompt for a new password (twice), followed by the message that &#8220;all authentication tokens have been updated&#8221;. Which is nice.</p>
<p>You can now login as &#8220;testuser&#8221; with your designated password. Testuser&#8217;s home directory is located here:</p>
<pre class="wp-code-highlight prettyprint">/home/testuser</pre>
<p>That&#8217;s all there&#8217;s to it &#8211; congratulations on creating a new user on your system <img src='http://wpguru.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/LsF-NyAN7Y0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/04/how-to-add-a-user-account-on-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/04/how-to-add-a-user-account-on-centos/</feedburner:origLink></item>
		<item>
		<title>How to parse a JSON URL in iOS and Cocoa</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/hPU8JtvAO04/</link>
		<comments>http://wpguru.co.uk/2013/04/how-to-parse-a-json-url-in-ios-and-cocoa/#comments</comments>
		<pubDate>Sun, 14 Apr 2013 13:03:28 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSURL]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-parse-a-json-url-in-ios-and-cocoa/</guid>
		<description><![CDATA[Both Cocoa and iOS have built-in methods to parse (and generate) JSON data using NSJSONSerialization. Most commonly you&#8217;ll want to call a URL with parameters which will return some data. You take this output and tell Objective-C that it&#8217;s JSON, then typecast the return to an array or a dictionary which in turn lets you [...]]]></description>
				<content:encoded><![CDATA[<p>Both Cocoa and iOS have built-in methods to parse (and generate) JSON data using NSJSONSerialization. </p>
<p>Most commonly you&#8217;ll want to call a URL with parameters which will return some data. You take this output and tell Objective-C that it&#8217;s JSON, then typecast the return to an array or a dictionary which in turn lets you access the data. It&#8217;s genius!</p>
<p>Here&#8217;s an example:</p>
<pre class="wp-code-highlight prettyprint">
// create the URL we&#039;d like to query
NSURL *myURL = [[NSURL alloc]initWithString:@&quot;<a href="http://domain.com/jsonquery&quot;" rel="nofollow">http://domain.com/jsonquery&quot;</a>;
        
// we&#039;ll receive raw data so we&#039;ll create an NSData Object with it 
NSData *myData = [[NSData alloc]initWithContentsOfURL:myURL];
        
// now we&#039;ll parse our data using NSJSONSerialization
id myJSON = [NSJSONSerialization JSONObjectWithData:myData options:NSJSONReadingMutableContainers error:nil];
        
// typecast an array and list its contents
NSArray *jsonArray = (NSArray *)myJSON;
        
// take a look at all elements in the array
for (id element in jsonArray) {
    NSLog(@&quot;Element: %@&quot;, [element description]);            
}
</pre>
<p>What you&#8217;ll get back depends on your individual JSON structure of course. This can be quite complex, for example you could receive an array full of dictionaries, each of which could be full of dictionaries. JSON data can be mapped to an NSArray, NSDictionary, NSNumberand NSNull.</p>
<p>Once you have access to the top level elements you can then loop through each one, examining what&#8217;s in it and access what you need.</p>
<h3>Further Reading</h3>
<ul>
<li>More details about the JSON Format: <a href="http://www.json.org/" rel="nofollow">http://www.json.org/</a></li>
<li>NSJSONSerialization Class Reference: <a href="http://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html" rel="nofollow">http://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html</a></li>
<li>JSONKit Framework: <a href="https://github.com/johnezang/JSONKit" rel="nofollow">https://github.com/johnezang/JSONKit</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/hPU8JtvAO04" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/04/how-to-parse-a-json-url-in-ios-and-cocoa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/04/how-to-parse-a-json-url-in-ios-and-cocoa/</feedburner:origLink></item>
		<item>
		<title>How to use a Selector</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/ClL_DCJ84zw/</link>
		<comments>http://wpguru.co.uk/2013/04/how-to-use-a-selector/#comments</comments>
		<pubDate>Mon, 08 Apr 2013 23:30:51 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-use-a-selector/</guid>
		<description><![CDATA[Just a quick reminder before I forget (again) how selectors are called: Some of Apple&#8217;s pre-written methods use whats known as a Selector. Here&#8217;s an example method that uses a selector: // create a bar button item UIBarButtonItem *linkButton = [[UIBarButtonItem alloc]initWithTitle:@"My Title" style:UIBarButtonItemStyleBordered target:self action:@selector(myMethod)]; Notice how the selector is created on the second [...]]]></description>
				<content:encoded><![CDATA[<p>Just a quick reminder before I forget (again) how selectors are called:</p>
<p>Some of Apple&#8217;s pre-written methods use whats known as a Selector. Here&#8217;s an example method that uses a selector:</p>
<pre class="wp-code-highlight prettyprint">
// create a bar button item
UIBarButtonItem *linkButton = [[UIBarButtonItem alloc]initWithTitle:@&quot;My Title&quot; style:UIBarButtonItemStyleBordered target:self action:@selector(myMethod)];
</pre>
<p>Notice how the selector is created on the second line. All it wants to know here is the method name really. Imagine you had a method called myMethod in the current class (hence the use of self here), this is how it gets called via the action parameter.</p>
<p>If you were to call this method just by itself, you&#8217;d use the usual</p>
<pre class="wp-code-highlight prettyprint">
[self myMethod];
</pre>
<p>For more information and how to build your own selectors, check out the <a href="http://developer.apple.com/library/ios/#documentation/General/Conceptual/DevPedia-CocoaCore/Selector.html%23//apple_ref/doc/uid/TP40008195-CH48-SW1">Cocoa Core Competencies section</a> on Selectors.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/ClL_DCJ84zw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/04/how-to-use-a-selector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/04/how-to-use-a-selector/</feedburner:origLink></item>
		<item>
		<title>How to remove the first n characters from an NSString</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/nuTOQM_0NM8/</link>
		<comments>http://wpguru.co.uk/2013/04/how-to-remove-the-first-n-characters-from-an-nsstring/#comments</comments>
		<pubDate>Fri, 05 Apr 2013 07:01:56 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSString]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-remove-the-first-n-characters-from-an-nsstring/</guid>
		<description><![CDATA[There&#8217;s a convenient method for that by the name of substringFromIndex. This example removes the first character: NSString *complete = @"12345"; NSString *cutOff = [complete substringFromIndex:1]; NSLog(@"%@", cutOff); // cutOff is now 2345 substringFromString takes only one parameter which specifies where to start the new string. The first character is 0 based, like in arrays. [...]]]></description>
				<content:encoded><![CDATA[<p>There&#8217;s a convenient method for that by the name of substringFromIndex. This example removes the first character:</p>
<pre class="wp-code-highlight prettyprint">
    NSString *complete = @&quot;12345&quot;;
    NSString *cutOff = [complete substringFromIndex:1];
    NSLog(@&quot;%@&quot;, cutOff);
    // cutOff is now 2345
</pre>
<p>substringFromString takes only one parameter which specifies where to start the new string. The first character is 0 based, like in arrays. The parameter can&#8217;t be longer than the original string&#8217;s length for obvious reasons.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/nuTOQM_0NM8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/04/how-to-remove-the-first-n-characters-from-an-nsstring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/04/how-to-remove-the-first-n-characters-from-an-nsstring/</feedburner:origLink></item>
		<item>
		<title>How to create a Fetch Request in the Xcode Model Editor</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/SvIlK01CV8g/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-create-a-fetch-request-in-the-xcode-model-editor/#comments</comments>
		<pubDate>Sun, 24 Mar 2013 22:48:21 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Core Data]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-create-a-fetch-request-in-the-xcode-model-editor/</guid>
		<description><![CDATA[You can create Fetch Requests in the Xcode model editor, including a Predicate. These are somewhat easier to setup. To create one, select your .xcdatamodeld file, then head over to Editor &#8211; Add Fetch Request. Give it a catchy name and a filter property, and much of the above code becomes obsolete. Here&#8217;s how you [...]]]></description>
				<content:encoded><![CDATA[<p>You can create Fetch Requests in the Xcode model editor, including a Predicate. These are somewhat easier to setup. To create one, select your .xcdatamodeld file, then head over to Editor &#8211; Add Fetch Request. Give it a catchy name and a filter property, and much of the above code becomes obsolete.</p>
<p>Here&#8217;s how you can retrieve one of those in code:</p>
<pre class="wp-code-highlight prettyprint">
    // create a fetch request from template
    NSFetchRequest *fetchRequest = [self.managedObjectModel fetchRequestTemplateForName:@&quot;MyFetch&quot;];
    
    NSArray *fetchedObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:nil];
    for (Event *event in fetchedObjects) {
        NSLog(@&quot;%@&quot;, [event.timeStamp description]);
    }
</pre>
<p>Note that to retrieve your Fetch Request Template you need a reference to your Managed Object Model as well as your context. The easiest way to grab hold of it in an iOS app is to pass it in on a property, just like we did with self.managedoObjectContext.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/SvIlK01CV8g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-create-a-fetch-request-in-the-xcode-model-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-create-a-fetch-request-in-the-xcode-model-editor/</feedburner:origLink></item>
		<item>
		<title>How to retrieve a Managed Object in Core Data Fetch Requests</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/MgHH57GAN88/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-retrieve-a-managed-object-in-core-data-fetch-requests/#comments</comments>
		<pubDate>Sun, 24 Mar 2013 18:19:54 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Core Data]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-retrieve-a-managed-object-in-core-data-using-basic-fetch-requests/</guid>
		<description><![CDATA[Retrieving Managed Objects is somewhat more complex than creating them, mainly because you can filter what you&#8217;re getting back rather than retrieve everything that your store file has to offer. Let&#8217;s first illustrate a basic NSFetchRequest. For the following examples I&#8217;m using the iOS Master/Detail template which provides an Entity called Event with a property [...]]]></description>
				<content:encoded><![CDATA[<p>Retrieving Managed Objects is somewhat more complex than creating them, mainly because you can filter what you&#8217;re getting back rather than retrieve everything that your store file has to offer.</p>
<p>Let&#8217;s first illustrate a basic NSFetchRequest. For the following examples I&#8217;m using the iOS Master/Detail template which provides an Entity called Event with a property called timeStamp. I&#8217;ve created custom subclasses for this entity. Press the add button a few times so we have some data, then quit the application.</p>
<h3>Basic Fetch Request</h3>
<p>Here&#8217;s how we can retrieve all our values using a basic Fetch Request:</p>
<pre class="wp-code-highlight prettyprint">    // create a fetch request
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@&quot;Event&quot; inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];

    // fetch all objects
    NSError *error = nil;
    NSArray *fetchedObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&amp;amp;error];
    if (fetchedObjects == nil) {
        NSLog(@&quot;Houston, we have a problem: %@&quot;, error);
    }

    // display all objects
    for (Event *event in fetchedObjects) {
        NSLog(@&quot;%@&quot;, [event.timeStamp description]);
    }</pre>
<p>The easiest way to get this code is by using a code snippet from the Xcode library (search for fetch, the first one is a &#8220;basic fetch&#8221;).</p>
<p>Note that the results are unfiltered, which means they&#8217;re not necessarily in the order you would like them to be in. To remedy this, you can use a Sort Descriptor:</p>
<h3>Fetch Request with Sort Descriptors</h3>
<pre class="wp-code-highlight prettyprint">    // create a fetch request
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@&quot;Event&quot; inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];

    // define a sort descriptor
    NSSortDescriptor *descriptor = [[NSSortDescriptor alloc]initWithKey:@&quot;timeStamp&quot; ascending:YES];
    NSArray *scArray = [[NSArray alloc]initWithObjects:descriptor, nil];

    // give sort descriptor array to the fetch request
    fetchRequest.sortDescriptors = scArray;

    // fetch all objects
    NSError *error = nil;
    NSArray *fetchedObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&amp;amp;error];
    if (fetchedObjects == nil) {
        NSLog(@&quot;Houston, we have a problem: %@&quot;, error);
    }

    // display all objects
    for (Event *event in fetchedObjects) {
        NSLog(@&quot;%@&quot;, [event.timeStamp description]);
    }</pre>
<p>You can pass more than one Sort Descriptor, hence we need to pass an NSArray to the fetch request. A usage example would be &#8220;list all employers alphabetically, in order of which they&#8217;ve started working&#8221;. To do this, create another sort descriptor, then add both to the array.</p>
<p>The easiest way to get this is to use the Xcode Code Snippets again, this time select the &#8220;fetch with sorting&#8221; and it will have all this code ready for you.</p>
<h3>Fetch Request using a Predicate</h3>
<p>Predicates are filters with which you can specify conditions, such as &#8220;is this date older than x&#8221;, &#8220;does the first name contain steve&#8221;, and so forth. I have written a more in-depth article on Predictates elsewhere on this site and won&#8217;t go into the details.</p>
<p>Here&#8217;s how you create a Fetch Request with a Predicate, combined with a Sort Descriptor:</p>
<pre class="wp-code-highlight prettyprint">    // create a fetch request
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@&quot;Event&quot; inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];
    
    // setup a predicate
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@&quot;timeStamp &amp;lt; %@&quot;, [NSDate date]];
    
    // give the predicate to the fetch request
    fetchRequest.predicate = predicate;
    
    // define a sort descriptor
    NSSortDescriptor *descriptor = [[NSSortDescriptor alloc]initWithKey:@&quot;timeStamp&quot; ascending:YES];
    NSArray *scArray = [[NSArray alloc]initWithObjects:descriptor, nil];
    
    // give sort descriptor array to the fetch request
    fetchRequest.sortDescriptors = scArray;
    
    // fetch all objects
    NSError *error = nil;
    NSArray *fetchedObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&amp;amp;error];
    if (fetchedObjects == nil) {
        NSLog(@&quot;Houston, we have a problem: %@&quot;, error);
    }
    
    // display all objects
    for (Event *event in fetchedObjects) {
        NSLog(@&quot;%@&quot;, [event.timeStamp description]);
    }</pre>
<p>&nbsp;</p>
<p>If you don&#8217;t need the Sort Descriptor, just remove that code from the example. This snippet is also available from Xcode and is called &#8220;fetch with predicate&#8221;.</p>
<p>For more information on Predicates, check out <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Predicates/predicates.html" >Apple&#8217;s Predicate Programming Guide</a>.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/MgHH57GAN88" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-retrieve-a-managed-object-in-core-data-fetch-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-retrieve-a-managed-object-in-core-data-fetch-requests/</feedburner:origLink></item>
		<item>
		<title>How to create a Managed Object in Core Data</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/BSNXTVl8bEg/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-create-a-managed-object-in-core-data/#comments</comments>
		<pubDate>Sun, 24 Mar 2013 17:43:55 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Core Data]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-create-a-managed-object-in-core-data/</guid>
		<description><![CDATA[Assuming you&#8217;re using an app template that includes Core Data, you will have access to the Managed Object Context. In the simplest form, and without custom Entity classes setup, you can use key/value coding to set your object&#8217;s properties. In fact, the Master/Detail template does this. Here&#8217;s an example for an Entity named Event with [...]]]></description>
				<content:encoded><![CDATA[<p>Assuming you&#8217;re using an app template that includes Core Data, you will have access to the Managed Object Context. In the simplest form, and without custom Entity classes setup, you can use key/value coding to set your object&#8217;s properties. In fact, the Master/Detail template does this.</p>
<p>Here&#8217;s an example for an Entity named Event with two properties (myKey and anotherKey):</p>
<pre class="wp-code-highlight prettyprint">
// create a managed object
NSManagedObject *myObject = [NSEntityDescription insertNewObjectForEntityForName:@&quot;Event&quot; inManagedObjectContext:self.managedObjectContext];
    
// set its attributes
[myObject setValue:@&quot;This is my value&quot; forKey:@&quot;myKey&quot;];
[myObject setValue:@&quot;My other value&quot; forKey:@&quot;anotherKey&quot;];
</pre>
<p>If you have created custom NSManagedObject subclasses for your Entity then you can create an object like this:</p>
<pre class="wp-code-highlight prettyprint">
// create a managed object from my custom class
Event *myObject = (Event *)[NSEntityDescription insertNewObjectForEntityForName:@&quot;Event&quot; inManagedObjectContext:self.managedObjectContext];
    
// set my object&#039;s properties
myObject.myKey = @&quot;This is my value&quot;;
myObject.anotherKey = @&quot;My other value&quot;;
</pre>
<p>The KVC method will always work, regardless if you have custom classes or not. Custom Classes have the advantage that you can add custom behaviour (i.e. methods), and of course code completion in Xcode.</p>
<p>Note that these snippets will create an object, but it your values are only stored once you save the Managed Object Context:</p>
<pre class="wp-code-highlight prettyprint">
[self.managedObjectContext save:nil];
</pre>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/BSNXTVl8bEg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-create-a-managed-object-in-core-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-create-a-managed-object-in-core-data/</feedburner:origLink></item>
		<item>
		<title>How to create a Save As dialogue with NSSavePanel</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/5PmxY0r_Pqg/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-create-a-save-as-dialogue-with-nssavepanel/#comments</comments>
		<pubDate>Thu, 21 Mar 2013 18:30:49 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-create-a-save-as-dialogue-with-nssavepanel/</guid>
		<description><![CDATA[Likewise we can save our previously selected file using an NSSavePanel. It too is easy to use, just as the NSOpenPanel. For a save action to make sense we need to have some data to save, so in this example we will copy an existing file (self.myURL) to the new URL that the save panel [...]]]></description>
				<content:encoded><![CDATA[<p>Likewise we can save our previously selected file using an NSSavePanel. It too is easy to use, just as the NSOpenPanel. </p>
<p>For a save action to make sense we need to have some data to save, so in this example we will copy an existing file (self.myURL) to the new URL that the save panel returns. We&#8217;ll let the NSFileManager just create a copy with a new name that the user specifies using the save panel:</p>
<pre class="wp-code-highlight prettyprint">
- (IBAction)saveFile:(id)sender {
    
    // create the save panel
    NSSavePanel *panel = [NSSavePanel savePanel];
    
    // set a new file name
    [panel setNameFieldStringValue:@&quot;NewFile.png&quot;];
    
    // display the panel
    [panel beginWithCompletionHandler:^(NSInteger result) {
        
        if (result == NSFileHandlingPanelOKButton) {
            
            // create a file namaner and grab the save panel&#039;s returned URL
            NSFileManager *manager = [NSFileManager defaultManager];
            NSURL *saveURL = [panel URL];
            
            // then copy a previous file to the new location
            [manager copyItemAtURL:self.myURL toURL:saveURL error:nil];
        }
    }];
    
}
</pre>
<p>The only alien looking thing here is the use of a Block (like it is in the NSOpenPanel). This is the equivalent to an anonymous function in JavaScript, basically a block of code that runs upon completion. As it&#8217;s part of the method call, the closing ] is way at the bottom.</p>
<h3>Further Reading</h3>
<p>Apple&#8217;s NSSavePanel Class Reference:</p>
<ul>
<li><a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSSavePanel_Class/Reference/Reference.html" rel="nofollow">https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSSavePanel_Class/Reference/Reference.html</a></li>
</ul>
<p>A Short Practical Guide to Blocks:</p>
<ul>
<li><a href="https://developer.apple.com/library/mac/#featuredarticles/Short_Practical_Guide_Blocks/" rel="nofollow">https://developer.apple.com/library/mac/#featuredarticles/Short_Practical_Guide_Blocks/</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/5PmxY0r_Pqg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-create-a-save-as-dialogue-with-nssavepanel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-create-a-save-as-dialogue-with-nssavepanel/</feedburner:origLink></item>
		<item>
		<title>How to create an Open File dialogue with NSOpenPanel</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/0uoARtHYbbk/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-create-an-open-file-dialogue-with-nsopenpanel/#comments</comments>
		<pubDate>Thu, 21 Mar 2013 18:19:05 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-create-an-open-file-dialogue-with-nsopenpanel/</guid>
		<description><![CDATA[NSOpenPanel is surprisingly easy to use: create the panel, call the openPanel method, and handle the returned URL object in a block. In this example we invoke the panel from a button in the main window, then display the returned URL in a textLabel: - (IBAction)loadFile:(id)sender { // create an open documet panel NSOpenPanel *panel [...]]]></description>
				<content:encoded><![CDATA[<p>NSOpenPanel is surprisingly easy to use: create the panel, call the openPanel method, and handle the returned URL object in a block. </p>
<p>In this example we invoke the panel from a button in the main window, then display the returned URL in a textLabel:</p>
<pre class="wp-code-highlight prettyprint">
- (IBAction)loadFile:(id)sender {
    
    // create an open documet panel
    NSOpenPanel *panel = [NSOpenPanel openPanel];
    
    // display the panel
    [panel beginWithCompletionHandler:^(NSInteger result) {
        if (result == NSFileHandlingPanelOKButton) {
            
            // grab a reference to what has been selected
            NSURL *theDocument = [[panel URLs]objectAtIndex:0];
            
            // write our file name to a label
            NSString *theString = [NSString stringWithFormat:@&quot;%@&quot;, theDocument];
            self.textLabel.stringValue = theString;
            
        }
    }];
    
}
</pre>
<h3>Further Reading</h3>
<p>Apple&#8217;s NSOpenPanel Class reference:</p>
<ul>
<li><a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSOpenPanel_Class/Reference/Reference.html" rel="nofollow">https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSOpenPanel_Class/Reference/Reference.html</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/0uoARtHYbbk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-create-an-open-file-dialogue-with-nsopenpanel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-create-an-open-file-dialogue-with-nsopenpanel/</feedburner:origLink></item>
		<item>
		<title>What to do if you’ve forgotten all credentials to your WordPress site</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/r9ANgv1pVU8/</link>
		<comments>http://wpguru.co.uk/2013/03/forgotten-everything/#comments</comments>
		<pubDate>Wed, 20 Mar 2013 12:00:01 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[Podcast]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpguru.co.uk/?p=3027</guid>
		<description><![CDATA[This podcast describes how to gain access to WordPress even without username, password or working email address. It&#8217;s happened to the best of us: you forgot your Password you forgot what User you are even worse, you&#8217;ve forgotten which email you&#8217;ve used when you installed WordPress worse still, your email no longer exists Fear not, [...]]]></description>
				<content:encoded><![CDATA[<p></p><p>This podcast describes how to gain access to WordPress even without username, password or working email address.</p>
<p>It&#8217;s happened to the best of us:</p>
<ul>
<li>you forgot your Password</li>
<li>you forgot what User you are</li>
<li>even worse, you&#8217;ve forgotten which email you&#8217;ve used when you installed WordPress</li>
<li>worse still, your email no longer exists</li>
</ul>
<p>Fear not, for in this week&#8217;s Podcast I will talk you through all these mishaps, and show you how you can still gain access to your WordPress site.</p>
<p>Enjoy!</p>
<p>&nbsp;</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='500' height='312' src='http://www.youtube.com/embed/rNimnObp9ns?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/r9ANgv1pVU8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/forgotten-everything/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://wpguru.co.uk/wp-content/uploads/podcast/206.mp4" length="117885889" type="video/mp4" />
		<itunes:subtitle>This podcast describes how to gain access to WordPress even without username, password or working email address. - It's happened to the best of us:  you forgot your Password   you forgot what User you are   even worse,</itunes:subtitle>
		<itunes:summary>This podcast describes how to gain access to WordPress even without username, password or working email address.

It's happened to the best of us:

	you forgot your Password
	you forgot what User you are
	even worse, you've forgotten which email you've used when you installed WordPress
	worse still, your email no longer exists

Fear not, for in this week's Podcast I will talk you through all these mishaps, and show you how you can still gain access to your WordPress site.

Enjoy!

 

http://youtu.be/rNimnObp9ns

 

 </itunes:summary>
		<itunes:author>Jay Versluis</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>10:26</itunes:duration>
		<rawvoice:isHD>yes</rawvoice:isHD>
		<rawvoice:poster url="http://wpguru.co.uk/wp-content/uploads/2013/03/206-Forgotten-Everything.001.jpg" />
	<feedburner:origLink>http://wpguru.co.uk/2013/03/forgotten-everything/</feedburner:origLink></item>
		<item>
		<title>How to pass data from the App Delegate to your Top View Controller</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/91dQMVBV4XI/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-pass-data-from-the-app-delegate-to-your-top-view-controller/#comments</comments>
		<pubDate>Wed, 20 Mar 2013 06:10:30 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Core Data]]></category>
		<category><![CDATA[UINavigationController]]></category>
		<category><![CDATA[UIViewController]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-pass-data-from-the-app-delegate-to-your-top-view-controller/</guid>
		<description><![CDATA[If the App Delegate has something that your top view controller needs then you simply pass it the required object via a property set on the top view controller. This is easy when your top view controller is also the root view controller. However, when you embed your top view controller in a Navigation Controller, [...]]]></description>
				<content:encoded><![CDATA[<p>If the App Delegate has something that your top view controller needs then you simply pass it the required object via a property set on the top view controller. This is easy when your top view controller is also the root view controller.</p>
<p>However, when you embed your top view controller in a Navigation Controller, and perhaps that one is also embedded in a Tab Bar Controller, then this array isn&#8217;t quite so easy to figure out (and I must admit that I always forget how to do this when a new challenge arises).</p>
<p>So here&#8217;s how this works. In this example, the thing that&#8217;s displayed is called MyViewController, which is embedded in a Navigation Controller. I&#8217;m passing it the App Delegate&#8217;s self.managedObjectContext which is defined as a property on MyViewController.</p>
<pre class="wp-code-highlight prettyprint">
// grab our own navigation controller
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
    
// grab our table view controller
MyViewController *myViewController = (MyViewController *)navigationController.topViewController;
    
// pass in whatever data you need (such as this):
myViewController.managedObjectContext = self.managedObjectContext;
</pre>
<p>We call this in the applicationDidFinishLaunching method, just before the return statement.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/91dQMVBV4XI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-pass-data-from-the-app-delegate-to-your-top-view-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-pass-data-from-the-app-delegate-to-your-top-view-controller/</feedburner:origLink></item>
		<item>
		<title>How to return the number of rows in a UITableView with Core Data</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/8701obcRZZg/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-return-the-number-of-rows-in-a-uitableview-with-core-data/#comments</comments>
		<pubDate>Mon, 18 Mar 2013 15:38:41 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Core Data]]></category>
		<category><![CDATA[UITableViewCell]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-return-the-number-of-rows-in-a-uitableview-with-core-data/</guid>
		<description><![CDATA[Likewise, here&#8217;s how we return the number of rows using a fetched results controller &#8211; as provided by the Master / Detail template: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [[self.fetchedResultsController sections] count]; }]]></description>
				<content:encoded><![CDATA[<p>Likewise, here&#8217;s how we return the number of rows using a fetched results controller &#8211; as provided by the Master / Detail template:</p>
<pre class="wp-code-highlight prettyprint">
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return [[self.fetchedResultsController sections] count];
}
</pre>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/8701obcRZZg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-return-the-number-of-rows-in-a-uitableview-with-core-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-return-the-number-of-rows-in-a-uitableview-with-core-data/</feedburner:origLink></item>
		<item>
		<title>How to return the number of sections in a UITableView with Core Data</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/n-HkIVoScbE/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-return-the-number-of-sections-in-a-uitableview-with-core-data/#comments</comments>
		<pubDate>Mon, 18 Mar 2013 15:36:15 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Core Data]]></category>
		<category><![CDATA[UITableView]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-return-the-number-of-sections-in-a-uitableview-with-core-data/</guid>
		<description><![CDATA[I can never remember how to do this. Here&#8217;s the method provided by the Master / Detail template when using Core Data: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { id &#60;NSFetchedResultsSectionInfo&#62; sectionInfo = [self.fetchedResultsController sections][section]; return [sectionInfo numberOfObjects]; }]]></description>
				<content:encoded><![CDATA[<p>I can never remember how to do this. Here&#8217;s the method provided by the Master / Detail template when using Core Data:</p>
<pre class="wp-code-highlight prettyprint">
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    id &lt;NSFetchedResultsSectionInfo&gt; sectionInfo = [self.fetchedResultsController sections][section];
    return [sectionInfo numberOfObjects];
}
</pre>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/n-HkIVoScbE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-return-the-number-of-sections-in-a-uitableview-with-core-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-return-the-number-of-sections-in-a-uitableview-with-core-data/</feedburner:origLink></item>
		<item>
		<title>How to convert a Persistent Store from XML to SQLite in Core Data</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/7pWqh4EWuxQ/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-convert-a-persistent-store-from-xml-to-sqlite-in-core-data/#comments</comments>
		<pubDate>Sun, 17 Mar 2013 23:11:10 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Core Data]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-convert-a-persistent-store-from-xml-to-sqlite-in-core-data/</guid>
		<description><![CDATA[By default Mac Apps use XML as store type when saving in Core Data, even though it can use other formats &#8211; such as SQLite, which is the default on iOS. Here&#8217;s a way to quickly convert one into the other. Note that this is designed as a one-off operation to create a new store [...]]]></description>
				<content:encoded><![CDATA[<p>By default Mac Apps use XML as store type when saving in Core Data, even though it can use other formats &#8211; such as SQLite, which is the default on iOS. Here&#8217;s a way to quickly convert one into the other.</p>
<p>Note that this is designed as a one-off operation to create a new store file which can be used in another application. Once run, comment the code out and either change your store file, or take the store file and use it in another app.</p>
<p>Add this code to the AppDelegate.m file in the persistenStore method (just before the return statement):</p>
<pre class="wp-code-highlight prettyprint">
// convert this thing to SQL
NSURL *sqlstore = [applicationFilesDirectory URLByAppendingPathComponent:@&quot;NewStoreFile.sqldata&quot;];
NSPersistentStore *xmlstore = [coordinator persistentStoreForURL:url];
    
[coordinator migratePersistentStore:xmlstore toURL:sqlstore options:nil withType:NSSQLiteStoreType error:nil];
</pre>
<p>For more information on how to do this in context, check out Simon Allardice&#8217;s superb course <a href="http://www.lynda.com/iOS-tutorials/Core-Data-iOS-OS-X/101461-2.html?utm_medium=affiliate&#038;utm_source=ldc_affiliate&%23038;utm_content=524&%23038;utm_campaign=CD14694&%23038;bid=524&%23038;aid=CD14694&%23038;opt=" >Core Data for iOS and OS X</a> on Lynda.com.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/7pWqh4EWuxQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-convert-a-persistent-store-from-xml-to-sqlite-in-core-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-convert-a-persistent-store-from-xml-to-sqlite-in-core-data/</feedburner:origLink></item>
		<item>
		<title>Binding an NSTableView to Core Data without code</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/A6oJVexKHKA/</link>
		<comments>http://wpguru.co.uk/2013/03/binding-an-nstableview-to-core-data-without-code/#comments</comments>
		<pubDate>Sun, 17 Mar 2013 20:09:49 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Core Data]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/binding-an-nstableview-to-core-data-without-code/</guid>
		<description><![CDATA[I was excited to find out that it is possible to write a Mac App with Core Data completely without code! This magic is possible with something that&#8217;s not available in iOS (yet) called Cocoa Bindings. You provide the user controls you need in Xcode, then control-drag your way to extensive functionality and happiness. Before [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright size-thumbnail wp-image-715" alt="Mountain Lion Logo" src="http://pinkstone.co.uk/wp-content/uploads/2013/03/mountain_lion_hero-150x150.jpg" width="150" height="150" />I was excited to find out that it is possible to write a Mac App with Core Data completely without code! This magic is possible with something that&#8217;s not available in iOS (yet) called Cocoa Bindings.</p>
<p>You provide the user controls you need in Xcode, then control-drag your way to extensive functionality and happiness. Before I forget, I thought I&#8217;d better make some notes.</p>
<p>Here&#8217;s a step-by-step list:</p>
<ul>
<li>Using Xcode, create a new Mac Cocoa Application with Core Data</li>
<li>Setup your entities and properties in your Core Data Model (.xcdatamodeld)</li>
<li>Create relationships between Entities if desired</li>
<li>Select all Entities and create custom classes from them (using Editor &#8211; create NSManagedObject Subclasses)</li>
</ul>
<p>Drag our friend the Array Controller onto the Object&#8217;s Bar. If you have multiple Entities, you need a separate Array Controller for each one. Change the labels to tell them apart (select a different file and go back to the xib in order for those labels to be visible &#8211; it&#8217;s a bug in Xcode).</p>
<p>Now bind the Array Controller and Core Data Managed Object Context together:</p>
<ul>
<li>Select your Array Controller, then go to the Bindings Inspector (second from the right)</li>
<li>Under Parameters, head over to the Managed Object Context and bind to the App Delegate (as that&#8217;s where Xcode has kindly prepared our Core Data stack)</li>
<li>In Model Key Path, type self.managedObjectContext (this should self complete)</li>
<li>In the Attributes Inspector, tell the controller that we&#8217;re using an Entity instead of a Class, then enter the Entity (it&#8217;s the one you&#8217;ve created in the data model)</li>
<li>While you&#8217;re here, tick the &#8220;Prepares Content&#8221; check box if you want the table view to be populated automatically</li>
</ul>
<p>Add a Table View to your window and bind it to the Array Controller:</p>
<ul>
<li>Select the Table View (inside the Scroll View) and head over to the Bindings Inspector</li>
<li>Under Table Content, select Bind To your Array Controller</li>
<li>Now select the actual Table Column you want to fill with data, and still inside the Bindings Inspector under Value, bind the column to your Array Controller</li>
<li>In the field for Model Key Path, type the attribute/property you&#8217;d like to see in this column (you&#8217;ve defined this in the data model)</li>
<li>Repeat the process for each column you want to fill with data</li>
</ul>
<p>To add data to your table:</p>
<ul>
<li>Add a couple of Gradient Buttons to your window</li>
<li>Make one the &#8220;Add&#8221; and one the &#8220;Delete&#8221; button</li>
<li>Hook up each button to the Array Controller via control drag, selecting add and remove respectively</li>
</ul>
<p>Congratulations: You&#8217;ve just created an editable Table View, hooked up to Core Data without a single line of code!</p>
<p>Let&#8217;s create a functional SAVE menu item</p>
<p>If you quit the app (rather than running it again from Xcode), all your data will save. However we can implement a manual save action with ease. The menu item itself is there by default, all we need to do is hook it up to the App Delegate and bind it to the save function.</p>
<p>In the Object Sidebar, select Main Menu, then select File &#8211; Save (which will expand the item in the sidebar too). From the save menu option, control drag to the App Delegate and select saveAction.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/A6oJVexKHKA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/binding-an-nstableview-to-core-data-without-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/binding-an-nstableview-to-core-data-without-code/</feedburner:origLink></item>
		<item>
		<title>How to assure your values are as intended with NSAssert</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/wI1te7HwvW4/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-assure-your-values-are-as-intended-with-nsassert/#comments</comments>
		<pubDate>Sun, 17 Mar 2013 03:55:40 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-assure-your-values-are-as-intended-with-nsassert/</guid>
		<description><![CDATA[NSAssert is a macro which allows you to test for specific values if and when they occur. Rather than having to figure out where your app has passed the wrong value several stages before a problem happened, NSAssert can be used like NSLog &#8211; with the helpful difference that if all is well, there&#8217;s no [...]]]></description>
				<content:encoded><![CDATA[<p>NSAssert is a macro which allows you to test for specific values if and when they occur. Rather than having to figure out where your app has passed the wrong value several stages before a problem happened, NSAssert can be used like NSLog &#8211; with the helpful difference that if all is well, there&#8217;s no log output.</p>
<p>Imagine your app is calculating a value. We can check if the value is as we had expected it to be:</p>
<pre class="wp-code-highlight prettyprint">
    // NSAssert Example (nothing happens)
    int i = 47;
    NSAssert(i == 47, @&quot;That didn&#039;t work&quot;);
</pre>
<p>In this case, everything is fine and we don&#8217;t see any log output. Let&#8217;s change the value to something else, and see our message together with a rather intimidating stack trace hit our log:</p>
<pre class="wp-code-highlight prettyprint">
    // NSAssert Example (will cause an exception)
    int i = 48;
    NSAssert(i == 47, @&quot;That didn&#039;t work&quot;);
</pre>
<p>You can also pass values and print them to the log. Depending on how many variables you pass, add a number to NSAssert like so:</p>
<pre class="wp-code-highlight prettyprint">
    // NSAssert Example (pass one value)
    int i = 48;
    NSAssert1(i == 47, @&quot;The real value is %i&quot;, i);
</pre>
<p>Use NSAssert2, NSAssert3 and so forth for more than one value.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/wI1te7HwvW4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-assure-your-values-are-as-intended-with-nsassert/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-assure-your-values-are-as-intended-with-nsassert/</feedburner:origLink></item>
		<item>
		<title>What is an Exception Breakpoint</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/D3hgUATtYq8/</link>
		<comments>http://wpguru.co.uk/2013/03/what-is-an-exception-breakpoint/#comments</comments>
		<pubDate>Sun, 17 Mar 2013 03:11:02 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/what-is-an-exception-breakpoint/</guid>
		<description><![CDATA[Sometimes Xcode just throws an error message that isn&#8217;t very helpful. That&#8217;s usually when we have to try and figure out why something didn&#8217;t go the way we expected it. Other times however, Xcode tells us very clearly which element it isn&#8217;t happy with &#8211; we fix it and our app progresses. Why can&#8217;t it [...]]]></description>
				<content:encoded><![CDATA[<p>Sometimes Xcode just throws an error message that isn&#8217;t very helpful. That&#8217;s usually when we have to try and figure out why something didn&#8217;t go the way we expected it. Other times however, Xcode tells us very clearly which element it isn&#8217;t happy with &#8211; we fix it and our app progresses. Why can&#8217;t it always be that way?</p>
<p>Well that&#8217;s because at those unhelpful times, Xcode is technically picking up an &#8220;exception&#8221;, but it tries to continue to run the programme. That&#8217;s when we end up with an error message which isn&#8217;t related to the actual problem.</p>
<p>An Exception Breakpoint can help. It&#8217;s something we can set and therefore force Xcode to stop when the problem occurs, not several lines later. Here&#8217;s how we do it:</p>
<ul>
<li>with the Navigator pane open, select the 6th tab from the left (the Breakpoint Navigator)</li>
<li>at the bottom left, click the plus sign to add a breakpoint</li>
<li>from the context menu select Add Exception Breakpoint</li>
<li>leave all default values and hit Done</li>
</ul>
<p>Next time Xcode will not try to be heroic and keep going. Instead, expect a more helpful error message.</p>
<p><img src="http://pinkstone.co.uk/wp-content/uploads/2013/03/Screen-Shot-2013-03-16-at-23.03.17.png" alt="Screen Shot 2013-03-16 at 23.03.17" width="481" height="315" class="aligncenter size-full wp-image-705" /></p>
<p>Also check out: <a href="https://developer.apple.com/library/ios/#recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html" rel="nofollow">https://developer.apple.com/library/ios/#recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html</a></p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/D3hgUATtYq8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/what-is-an-exception-breakpoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/what-is-an-exception-breakpoint/</feedburner:origLink></item>
		<item>
		<title>How to increase the number of simultaneous IMAP connections in Plesk</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/lfA6DArlObw/</link>
		<comments>http://wpguru.co.uk/2013/03/plesk-imap-connections/#comments</comments>
		<pubDate>Thu, 14 Mar 2013 22:42:01 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[cenots]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://wpguru.co.uk/?p=3168</guid>
		<description><![CDATA[By default Plesk sets up the IMAP Email Service on your server so that four simultaneous connections can be made from the same IP address in the same timeframe. This is to protect your servers from too many connections. This however isn&#8217;t cutting it if you have a small office full of people on the [...]]]></description>
				<content:encoded><![CDATA[<p></p><p><img class="alignright size-thumbnail wp-image-1653" alt="Plesk-Logo" src="http://wpguru.co.uk/wp-content/uploads/2011/11/Plesk-Logo-150x150.png" width="150" height="150" />By default Plesk sets up the IMAP Email Service on your server so that four simultaneous connections can be made from the same IP address in the same timeframe. This is to protect your servers from too many connections.</p>
<p>This however isn&#8217;t cutting it if you have a small office full of people on the same IP, connecting from 4 computers, 16 iphones and 12 iPads every 5 minutes.</p>
<p>The solution: tweak the IMAP configuration file, restart the daemon and have a good life. Let me show you how to do it on Plesk 11 and CentOS 6.4.</p>
<p><span id="more-3168"></span></p>
<p>The file you&#8217;ll want to tweak is called imapd and lives in</p>
<p><strong>/etc/courier-imap/imapd</strong></p>
<p>Log in to your server with root credentials and edit the file with your favourite text editor (like vi). Near the top you&#8217;ll find the following lines. They&#8217;re not directly underneath each other, but instead are separated by helpful comments to explain what they do:</p>
<pre class="wp-code-highlight prettyprint">MAXDAEMONS = 40
MAXPERIP = 4</pre>
<p>You may have guessed what these do: the first limits the amount of simultaneous IMAP daemons at the same time, while the second one limits the amount of simultaneous connections from the same IP at the same time. Change them according to your needs: perhaps count the amount of devices/services that connect, then add a few more for good measure.</p>
<p>I&#8217;m setting mine to 80 daemons and 20 IP connections like so:</p>
<pre class="wp-code-highlight prettyprint">MAXDAEMONS = 80
MAXPERIP = 20</pre>
<p>Next we need to restart the IMAP service for the changes to take effect:</p>
<pre class="wp-code-highlight prettyprint">service courier-imap restart</pre>
<p>Alternatively you can restart the service like this:</p>
<pre class="wp-code-highlight prettyprint">/etc/init.d/courier-imap stop
/etc/init.d/courier-imap start</pre>
<p>The rest, as they say, is history.</p>
<h3>Help! I&#8217;ve messed up that file!</h3>
<p>Fear not &#8211; here&#8217;s a clean copy, taken from Plesk 11.0.9 on CentOS 6.4. Just in case:</p>
<ul>
<li><a href="http://wpguru.co.uk/wp-content/uploads/2013/03/Default-imapd-config-Plesk-11.zip">Default imapd file</a> (6kB)</li>
</ul>
<h3>Further Reading</h3>
<ul>
<li><a href="http://kb.parallels.com/en/113841" target="_blank">Parallels KB article</a> explaining this process</li>
</ul>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/lfA6DArlObw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/plesk-imap-connections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/plesk-imap-connections/</feedburner:origLink></item>
		<item>
		<title>How to split long Posts and Pages</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/m0uZOKjMY70/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-split-long-posts-and-pages/#comments</comments>
		<pubDate>Wed, 13 Mar 2013 12:00:22 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[Podcast]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[long posts]]></category>
		<category><![CDATA[more]]></category>
		<category><![CDATA[nextpage]]></category>
		<category><![CDATA[split]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpguru.co.uk/?p=2999</guid>
		<description><![CDATA[In this podcast I will show you how to use the MORE and NEXTPAGE features in WordPress. These are built-in tags that will make your posts look their best: MORE can break your post off on the front page, so instead of the entire post being displayed you can choose where WordPress inserts a &#8220;read [...]]]></description>
				<content:encoded><![CDATA[<p></p><p>In this podcast I will show you how to use the MORE and NEXTPAGE features in WordPress.</p>
<p>These are built-in tags that will make your posts look their best: MORE can break your post off on the front page, so instead of the entire post being displayed you can choose where WordPress inserts a &#8220;read more&#8221; message.</p>
<p>NEXTPAGE is a related feature that works on single posts and pages by inserting a virtual &#8220;break point&#8221; so that your long posts (or pages) are split into multiple parts.</p>
<p>Download the <a href="http://wordpress.org/extend/plugins/nextpage-buttons/" target="_blank">Nextpage Buttons plugin</a> I&#8217;m talking about in this screencast <a href="http://wordpress.org/extend/plugins/nextpage-buttons/" target="_blank">here</a>.</p>
<p>As always, enjoy!</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='500' height='312' src='http://www.youtube.com/embed/vs-gyzu2zTA?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/m0uZOKjMY70" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-split-long-posts-and-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://wpguru.co.uk/wp-content/uploads/podcast/205.mp4" length="211142558" type="video/mp4" />
			<itunes:keywords>feature,long posts,more,nextpage,split,WordPress</itunes:keywords>
	<itunes:subtitle>In this podcast I will show you how to use the MORE and NEXTPAGE features in WordPress. - These are built-in tags that will make your posts look their best: MORE can break your post off on the front page, so instead of the entire post being displayed ...</itunes:subtitle>
		<itunes:summary>In this podcast I will show you how to use the MORE and NEXTPAGE features in WordPress.

These are built-in tags that will make your posts look their best: MORE can break your post off on the front page, so instead of the entire post being displayed you can choose where WordPress inserts a "read more" message.

NEXTPAGE is a related feature that works on single posts and pages by inserting a virtual "break point" so that your long posts (or pages) are split into multiple parts.

Download the Nextpage Buttons plugin I'm talking about in this screencast here.

As always, enjoy!

http://youtu.be/vs-gyzu2zTA

 </itunes:summary>
		<itunes:author>Jay Versluis</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>10:16</itunes:duration>
		<rawvoice:isHD>yes</rawvoice:isHD>
		<rawvoice:poster url="http://wpguru.co.uk/wp-content/uploads/2013/02/205-Long-Posts.jpg" />
	<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-split-long-posts-and-pages/</feedburner:origLink></item>
		<item>
		<title>How to activate a UISearchDisplayController</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/7ejYXgGh9Ts/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-activate-a-uisearchdisplaycontroller/#comments</comments>
		<pubDate>Sat, 09 Mar 2013 16:39:00 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-activate-a-uisearchdisplaycontroller/</guid>
		<description><![CDATA[We can do this two ways: // version 1: [self.searchBar becomeFirstResponder]; // version 2: [self.searchDisplayController setActive:YES animated:YES]; The benefit of version 2 is that if we perform it &#8220;in vision&#8221;, we can use the animated option and make it look all swish. Version 2 of course also has a reverse with which we can deactivate [...]]]></description>
				<content:encoded><![CDATA[<p>We can do this two ways:</p>
<pre class="wp-code-highlight prettyprint">
    // version 1:
    [self.searchBar becomeFirstResponder];

    // version 2:
    [self.searchDisplayController setActive:YES animated:YES];
</pre>
<p>The benefit of version 2 is that if we perform it &#8220;in vision&#8221;, we can use the animated option and make it look all swish. </p>
<p>Version 2 of course also has a reverse with which we can deactivate the controller:</p>
<pre class="wp-code-highlight prettyprint">
    [self.searchDisplayController setActive:NO animated:YES];
</pre>
<p>Note that this will not affect the UISearchBar associated with the search display controller; you need to deal with that separately.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/7ejYXgGh9Ts" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-activate-a-uisearchdisplaycontroller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-activate-a-uisearchdisplaycontroller/</feedburner:origLink></item>
		<item>
		<title>How to remove the last n characters from an NSString</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/qvcpjdeMpm8/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-extract-the-last-n-characters-from-an-nsstring/#comments</comments>
		<pubDate>Sat, 09 Mar 2013 05:55:21 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSString]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-remove-the-last-n-characters-from-an-nsstring/</guid>
		<description><![CDATA[We can use the substringToIndex method for this, using the length of our original string minus 1: NSString *something = @"12345"; something = [something substringToIndex:(something.length - 1)]; // something is now 1234]]></description>
				<content:encoded><![CDATA[<p>We can use the substringToIndex method for this, using the length of our original string minus 1:</p>
<pre class="wp-code-highlight prettyprint">
        NSString *something = @&quot;12345&quot;;
        something = [something substringToIndex:(something.length - 1)];
        
        // something is now 1234
</pre>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/qvcpjdeMpm8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-extract-the-last-n-characters-from-an-nsstring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-extract-the-last-n-characters-from-an-nsstring/</feedburner:origLink></item>
		<item>
		<title>How to extract first n characters of an NSString</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/2I0uHm4W0TI/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-extract-first-n-characters-of-an-nsstring/#comments</comments>
		<pubDate>Sat, 09 Mar 2013 06:02:34 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSString]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-extract-a-portion-of-an-nsstring/</guid>
		<description><![CDATA[We can use substringWithRange for this, which requires us to define a range: NSString *something = @"123456789"; NSRange myRange = NSMakeRange(2, 3); something = [something substringWithRange:myRange]; // something is now 345 You create a range by specifying where the substring should start (the first character is 0, like in an array), then specify how many [...]]]></description>
				<content:encoded><![CDATA[<p>We can use substringWithRange for this, which requires us to define a range:</p>
<pre class="wp-code-highlight prettyprint">
        NSString *something = @&quot;123456789&quot;;
        NSRange myRange = NSMakeRange(2, 3);
        something = [something substringWithRange:myRange];

        // something is now 345
</pre>
<p>You create a range by specifying where the substring should start (the first character is 0, like in an array), then specify how many characters from there you want to use.</p>
<p>To grab just the first character you&#8217;d specify a range like this:</p>
<pre class="wp-code-highlight prettyprint">
        NSString *something = @&quot;123456789&quot;;
        NSRange myRange = NSMakeRange(0, 1);
        something = [something substringWithRange:myRange];

        // something is now 1
</pre>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/2I0uHm4W0TI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-extract-first-n-characters-of-an-nsstring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-extract-first-n-characters-of-an-nsstring/</feedburner:origLink></item>
		<item>
		<title>How to create your own Data Type using typedef</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/gsCsH20Qn8c/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-create-your-own-data-type-using-typedef/#comments</comments>
		<pubDate>Thu, 07 Mar 2013 15:02:38 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[enum]]></category>
		<category><![CDATA[typedef]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-create-your-own-data-type-using-typedef/</guid>
		<description><![CDATA[With typedef you can specify custom variable types. Instead of having a variable such as int, you could create your own &#8211; such as yourInt: // create a typedef of int typedef int yourInt; yourInt yourValue = 57; NSLog(@"Your value is %i", yourValue); Now you have your own variable type called youInt which behaves just [...]]]></description>
				<content:encoded><![CDATA[<p>With typedef you can specify custom variable types. Instead of having a variable such as int, you could create your own &#8211; such as yourInt:</p>
<pre class="wp-code-highlight prettyprint">
// create a typedef of int
        typedef int yourInt;
        yourInt yourValue = 57;
        
        NSLog(@&quot;Your value is %i&quot;, yourValue);
</pre>
<p>Now you have your own variable type called youInt which behaves just like an int. </p>
<p>The power of typedef becomes clearer when combined with enumerations we were discussing previously. You can create your own data type of enum, creating and addressing your values more easily. Let&#8217;s stick with the drink size example from earlier:</p>
<pre class="wp-code-highlight prettyprint">
// create a typedef of enum drinkSize
        typedef enum drinkSize {
            smallDrink = 1,
            mediumDrink = 50,
            largeDrink = 100
        } drinkSize;
        
        // declare a variable from my typedef enumeration set
        drinkSize myDrink = largeDrink;
        drinkSize juliasDrink = smallDrink;

</pre>
<p>Xcode will code complete all available values, making your life a bit easier when coding. </p>
<p>Many of Apple&#8217;s pre-defined super long complex types are created this way. Think of all those NSDateFormatter values you can use, such as NSDateFormatterStyleLongStyle.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/gsCsH20Qn8c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-create-your-own-data-type-using-typedef/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-create-your-own-data-type-using-typedef/</feedburner:origLink></item>
		<item>
		<title>How to create an Enumeration (enum)</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/oGOT0ciAoSk/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-create-an-enumeration-enum/#comments</comments>
		<pubDate>Thu, 07 Mar 2013 14:43:30 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[enum]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-create-an-enumeration-enum/</guid>
		<description><![CDATA[An Enumeration (enum) allows you to create a collection of custom values. These can be more meaningful than simply using numbers. Imagine you want to track drink sizes, such as small, medium and large. You can remember to just use the numbers 1, 2 and 3 for each size &#8211; but Enumeration makes it easier [...]]]></description>
				<content:encoded><![CDATA[<p>An Enumeration (enum) allows you to create a collection of custom values. These can be more meaningful than simply using numbers. </p>
<p>Imagine you want to track drink sizes, such as small, medium and large. You can remember to just use the numbers 1, 2 and 3 for each size &#8211; but Enumeration makes it easier to declare those.</p>
<pre class="wp-code-highlight prettyprint">
// create an enumeration
        enum drinkSize {
            smallDrink = 1,
            mediumDrink = 50,
            largeDrink = 100
        };
        
        // declare a variable from my enumeration set
        enum drinkSize myDrink = largeDrink;
        
        // compare against my own values
        if (myDrink == largeDrink) {
            NSLog(@&quot;That&#039;s my drink!&quot;);
        }
        
        // an enum behaves like an integer
        NSLog(@&quot;My Drink Size is %i&quot;, myDrink);
</pre>
<p>Notice the last line: when written in a string like a log message, Objective-C will track your enumeration&#8217;s numeric values instead. In my case, the log message would display &#8220;My Drink Size is 100&#8243;.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/oGOT0ciAoSk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-create-an-enumeration-enum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-create-an-enumeration-enum/</feedburner:origLink></item>
		<item>
		<title>How to create an NSIndexPath and specify its components</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/BQbryyoYvd0/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-create-an-nsindexpath-and-specify-its-components/#comments</comments>
		<pubDate>Thu, 07 Mar 2013 04:27:32 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSIndexPath]]></category>
		<category><![CDATA[UITableView]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-create-an-nsindexpath-and-specify-its-components/</guid>
		<description><![CDATA[On occasion we need to create an NSIndexPath manually, with components we specify (such as a row or a section). There&#8217;s a method for that: indexPath:forItem:inSection. Here&#8217;s how you create an indexPath for row 0, section 0: NSIndexPath *indexPath = [[NSIndexPath alloc]init]; indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; The method takes two integers. You can even [...]]]></description>
				<content:encoded><![CDATA[<p>On occasion we need to create an NSIndexPath manually, with components we specify (such as a row or a section). There&#8217;s a method for that: indexPath:forItem:inSection.</p>
<p>Here&#8217;s how you create an indexPath for row 0, section 0:</p>
<pre class="wp-code-highlight prettyprint">
NSIndexPath *indexPath = [[NSIndexPath alloc]init];
indexPath = [NSIndexPath indexPathForItem:0 inSection:0];
</pre>
<p>The method takes two integers. You can even take an existing indexPath, then add or subtract values to the new indexPath, like so:</p>
<pre class="wp-code-highlight prettyprint">
// current indexPath
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];

// make a new indexPath and add 1 to the row of the previous one
NSIndexPath *indexPath2 = [[NSIndexPath alloc]init];
indexPath2 = [NSIndexPath indexPathForItem:(indexPath.row + 1) inSection:indexPath.section];
</pre>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/BQbryyoYvd0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-create-an-nsindexpath-and-specify-its-components/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-create-an-nsindexpath-and-specify-its-components/</feedburner:origLink></item>
		<item>
		<title>Hilarious Xcode Error Message</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/R07r2yfoD68/</link>
		<comments>http://wpguru.co.uk/2013/03/hilarious-xcode-error-message/#comments</comments>
		<pubDate>Thu, 07 Mar 2013 04:53:01 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://wpguru.co.uk/?p=3081</guid>
		<description><![CDATA[I&#8217;ve been working on an iOS App recently which deals with several date methods. Usually when something goes wrong Xcode displays very dry messages such as &#8220;Array out of bounds&#8221; or something rather unhelpful (like the complete stack output with no clue as to what actually went wrong). I was accidentally passing nil into an [...]]]></description>
				<content:encoded><![CDATA[<p></p><p><img class="alignright size-thumbnail wp-image-2377" alt="Xcode_icon" src="http://wpguru.co.uk/wp-content/uploads/2012/12/Xcode_icon-150x150.png" width="150" height="150" />I&#8217;ve been working on an iOS App recently which deals with several date methods. Usually when something goes wrong Xcode displays very dry messages such as &#8220;Array out of bounds&#8221; or something rather unhelpful (like the complete stack output with no clue as to what actually went wrong).</p>
<p>I was accidentally passing nil into an NSDateComponents method &#8211; and instead of crashing (which is what I would have expected), Xcode displayed this super funny message in the log console:</p>
<blockquote><p><em>[__NSCFCalendar components:fromDate:toDate:options:]: </em></p>
<p><em>toDate cannot be nil</em></p>
<p><em>I mean really, what do you think that operation is supposed to mean with a nil toDate? </em></p>
<p><em>An exception has been avoided for now. A few of these errors are going to be reported with this complaint, then further violations will simply silently do whatever random thing results from the nil.</em></p></blockquote>
<p>It made me smile <img src='http://wpguru.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><span id="more-3081"></span></p>
<p>I think we should have more error messages like this! Here&#8217;s a screenshot:</p>
<div id="attachment_3084" class="wp-caption aligncenter" style="width: 490px"><a href="http://wpguru.co.uk/wp-content/uploads/2013/03/Screen-Shot-2013-03-06-at-23.37.59.png"><img class="size-large wp-image-3084" alt="Xcode can be funny after all" src="http://wpguru.co.uk/wp-content/uploads/2013/03/Screen-Shot-2013-03-06-at-23.37.59-480x325.png" width="480" height="325" /></a><p class="wp-caption-text">Xcode can be funny after all</p></div>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/R07r2yfoD68" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/hilarious-xcode-error-message/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/hilarious-xcode-error-message/</feedburner:origLink></item>
		<item>
		<title>How to add some time to an NSDate</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/paL83wXT-v4/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-add-some-time-to-an-nsdate/#comments</comments>
		<pubDate>Thu, 07 Mar 2013 04:07:03 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSCalendar]]></category>
		<category><![CDATA[NSDate]]></category>
		<category><![CDATA[NSDateComponents]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-add-some-time-to-an-nsdate/</guid>
		<description><![CDATA[Imagine you had an NSDate object and want to add days several to it. We can use NSDate method dateByAddingComponents for this, which takes &#8211; as you may have guessed &#8211; NSDateComponents as parameters. In this example, let&#8217;s assume we want to know what date it is 5 days from today: int daysToAdd = 5; [...]]]></description>
				<content:encoded><![CDATA[<p>Imagine you had an NSDate object and want to add days several to it. We can use NSDate method dateByAddingComponents for this, which takes &#8211; as you may have guessed &#8211; NSDateComponents as parameters.</p>
<p>In this example, let&#8217;s assume we want to know what date it is 5 days from today: </p>
<pre class="wp-code-highlight prettyprint">
int daysToAdd = 5;
NSDate *today = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [[NSDateComponents alloc]init];
[components setDay:daysToAdd];
NSDate *futureDate = [gregorian dateByAddingComponents:components toDate:today options:0];
</pre>
<p>You can add as many and diverse components you like, such as</p>
<ul>
<li>setEra:</li>
<li>setYear:</li>
<li>setMonth:</li>
<li>setDay:</li>
<li>setHour:</li>
<li>setMinute:</li>
<li>setSecond:</li>
<li>setWeek:</li>
<li>setWeekday:</li>
<li>setWeekdayOrdinal:</li>
<li>setQuarter:</li>
<li>setCalendar:</li>
<li>setTimeZone:</li>
<li>setWeekOfMonth:</li>
<li>setWeekOfYear:</li>
<li>setYearForWeekOfYear:</li>
</ul>
<p>Check out the NSDateComponents Class Reference for more information.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/paL83wXT-v4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-add-some-time-to-an-nsdate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-add-some-time-to-an-nsdate/</feedburner:origLink></item>
		<item>
		<title>How to normalize NSDate objects (i.e. set the time to midnight)</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/VGQ0xz7CXC4/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-normalize-nsdate-objects-i-e-set-the-time-to-midnight/#comments</comments>
		<pubDate>Wed, 06 Mar 2013 16:18:40 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSDate]]></category>
		<category><![CDATA[NSDateComponents]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-normalize-nsdate-objects-i-e-set-the-time-to-midnight/</guid>
		<description><![CDATA[When you create new date using [NSDate date] (i.e. today, as in right now) your date will save the current time as well as its date. In fact, under the hood an NSDate object is the amount of seconds that have elapsed since the 1st of January 2001 (or 1970), in milliseconds. So really it&#8217;s [...]]]></description>
				<content:encoded><![CDATA[<p>When you create new date using [NSDate date] (i.e. today, as in right now) your date will save the current time as well as its date. </p>
<p>In fact, under the hood an NSDate object is the amount of seconds that have elapsed since the 1st of January 2001 (or 1970), in milliseconds. So really it&#8217;s a massive floating point number. You can see what it is with this code:</p>
<pre class="wp-code-highlight prettyprint">
NSLog(@&quot;Since 1970: %f&quot;, [today timeIntervalSince1970]);
NSLog(@&quot;Since 2001: %f&quot;, [today timeIntervalSinceReferenceDate]);
</pre>
<p>To save you the trouble, it&#8217;s bee roughly 1362585768.752258 seconds since 1970. But I digress&#8230;</p>
<p>Sometimes you want the date objects you&#8217;re dealing with not to regard &#8220;time&#8221; and really only deal with dates. As such, all dates &#8211; to be comparable &#8211; need to have the very same time, say midnight. Otherwise you may get the wrong results. Imagine adding three date objects that each have noon as their time, that&#8217;s an extra day and a half clouding your results right there.</p>
<p>Here&#8217;s some code that will normalize your NSDate object by setting its time to midnight:</p>
<pre class="wp-code-highlight prettyprint">
// normalizing a date
NSDate *yourDate = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:yourDate];
        
yourDate = [gregorian dateFromComponents:dateComponents];
        
NSLog(@&quot;Now your date starts at midnight: %@&quot;, yourDate);
</pre>
<p>In a nutshell, we &#8220;explode&#8221; the date into its year, month and day components, and then recreate a new object with these and no other components.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/VGQ0xz7CXC4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-normalize-nsdate-objects-i-e-set-the-time-to-midnight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-normalize-nsdate-objects-i-e-set-the-time-to-midnight/</feedburner:origLink></item>
		<item>
		<title>How to determine how many days / months / years have passed between two NSDate objects</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/XPlAWkVBgH8/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-determine-how-many-days-months-years-have-passed-between-two-nsdate-objects/#comments</comments>
		<pubDate>Wed, 06 Mar 2013 15:52:03 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[NSCalendar]]></category>
		<category><![CDATA[NSDate]]></category>
		<category><![CDATA[NSDateComponents]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-determine-how-many-days-months-years-have-passed-between-two-nsdate-objects/</guid>
		<description><![CDATA[Imagine you had two NSDate objects and you&#8217;d like to find out the time interval between those dates. NSDate objects alone won&#8217;t help us out there unless we do some serious NSDateFormatting and hair pulling. Lucky for us there are a few other classes available that will help us do this, namely NSCalendar and NSDateComponents. [...]]]></description>
				<content:encoded><![CDATA[<p>Imagine you had two NSDate objects and you&#8217;d like to find out the time interval between those dates. NSDate objects alone won&#8217;t help us out there unless we do some serious NSDateFormatting and hair pulling.</p>
<p>Lucky for us there are a few other classes available that will help us do this, namely NSCalendar and NSDateComponents.</p>
<p>&nbsp;</p>
<h3>Years, Months and Days</h3>
<p>Here&#8217;s how you can determine how many years, months and days have passed between two NSDates:</p>
<pre class="wp-code-highlight prettyprint">NSDate *earlier = [[NSDate alloc]initWithTimeIntervalSinceReferenceDate:1];
NSDate *today = [NSDate date];

NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];

// pass as many or as little units as you like here, separated by pipes
NSUInteger units = NSYearCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit;

NSDateComponents *components = [gregorian components:units fromDate:earlier toDate:today options:0];

NSInteger years = [components year];
NSInteger months = [components month];
NSInteger days = [components day];

NSLog(@&quot;Years: %ld, Months: %ld, Days: %ld&quot;, (long)years, (long)months, (long)days);</pre>
<p>The above example returns Years: 12, Months: 2, Days: 5.</p>
<p>In a nutshell we split the date into &#8220;components&#8221; such as years, months and days, and let the NSDateComponents class give us those as NSIntegers (i.e. long integers). For the class to calculate this correctly we need to put our days into the context of an NSCalendar (gregorian in our case). This is important because different calendars may return different time intervals.</p>
<p>&nbsp;</p>
<h3>Just the Days</h3>
<p>If you&#8217;re interested in just one particular item (days for example) just leave out any other component on this line:</p>
<pre class="wp-code-highlight prettyprint">// just the days
NSUInteger units = NSDayCalendarUnit;
</pre>
<h3></h3>
<h3>How about other units?</h3>
<p>You can pass as many of those fast enumeration units as you like, separated by pipes. For a full list of available values check out the NSCalendar Class Reference</p>
<p>&nbsp;</p>
<h3>Further Reading</h3>
<ul>
<li>NS Calendar Class Reference: <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSCalendar_Class/Reference/NSCalendar.html" rel="nofollow">https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSCalendar_Class/Reference/NSCalendar.html</a></li>
<li>Date and Time Programming Guide: <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DatesAndTimes/DatesAndTimes.html" rel="nofollow">https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DatesAndTimes/DatesAndTimes.html</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/XPlAWkVBgH8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-determine-how-many-days-months-years-have-passed-between-two-nsdate-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-determine-how-many-days-months-years-have-passed-between-two-nsdate-objects/</feedburner:origLink></item>
		<item>
		<title>How to avoid Spam User Registrations</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/JpughM0gvA8/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-avoid-spam-user-registrations/#comments</comments>
		<pubDate>Wed, 06 Mar 2013 13:00:15 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[Podcast]]></category>

		<guid isPermaLink="false">http://wpguru.co.uk/?p=2995</guid>
		<description><![CDATA[In this podcast I will show you how to disable user registrations on your WordPress website. If you don&#8217;t have a legitimate reason to invite users to register themselves you&#8217;re leaving your site open to spammers who may from time to time try to &#8220;get in&#8221; (and we want to make sure we keep them [...]]]></description>
				<content:encoded><![CDATA[<p></p><p>In this podcast I will show you how to disable user registrations on your WordPress website. If you don&#8217;t have a legitimate reason to invite users to register themselves you&#8217;re leaving your site open to spammers who may from time to time try to &#8220;get in&#8221; (and we want to make sure we keep them out).</p>
<p>If you&#8217;re receiving weird emails from your website that tell you somebody new has registered and you don&#8217;t know what this means, this podcast is for you.</p>
<p>Enjoy!</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='500' height='312' src='http://www.youtube.com/embed/WwuN4S8ssJE?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/JpughM0gvA8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-avoid-spam-user-registrations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://wpguru.co.uk/wp-content/uploads/podcast/204.mp4" length="50725974" type="video/mp4" />
		<itunes:subtitle>In this podcast I will show you how to disable user registrations on your WordPress website. If you don't have a legitimate reason to invite users to register themselves you're leaving your site open to spammers who may from time to time try to "get in...</itunes:subtitle>
		<itunes:summary>In this podcast I will show you how to disable user registrations on your WordPress website. If you don't have a legitimate reason to invite users to register themselves you're leaving your site open to spammers who may from time to time try to "get in" (and we want to make sure we keep them out).

If you're receiving weird emails from your website that tell you somebody new has registered and you don't know what this means, this podcast is for you.

Enjoy!

http://youtu.be/WwuN4S8ssJE

 </itunes:summary>
		<itunes:author>Jay Versluis</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>5:17</itunes:duration>
		<rawvoice:isHD>yes</rawvoice:isHD>
		<rawvoice:poster url="http://wpguru.co.uk/wp-content/uploads/2013/02/204-Spam-User-Registration.001.jpg" />
	<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-avoid-spam-user-registrations/</feedburner:origLink></item>
		<item>
		<title>How to pop a UINavigationController in code</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/7fRzMDiW67c/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-pop-a-uinavigationcontroller-in-code/#comments</comments>
		<pubDate>Mon, 04 Mar 2013 01:04:31 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[UINavigationController]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-pop-a-uinavigationcontroller-in-code/</guid>
		<description><![CDATA[In UINavigationController speak, we &#8220;push&#8221; new controllers onto the stack (go forward), and we &#8220;pop&#8221; them off the stack (go back). The navigation controller handles all this for us. If you want to go back exactly one view controller, here&#8217;s how you can do it programmatically: // pop back to previous controller NSArray *myControllers = [...]]]></description>
				<content:encoded><![CDATA[<p>In UINavigationController speak, we &#8220;push&#8221; new controllers onto the stack (go forward), and we &#8220;pop&#8221; them off the stack (go back). The navigation controller handles all this for us.</p>
<p>If you want to go back exactly one view controller, here&#8217;s how you can do it programmatically:</p>
<pre class="wp-code-highlight prettyprint">
    // pop back to previous controller
    NSArray *myControllers = self.navigationController.viewControllers;
    int previous = myControllers.count - 2;
    UIViewController *previousController = [myControllers objectAtIndex:previous];
    
    [self.navigationController popToViewController:previousController animated:YES];
</pre>
<p>First we access the array of all view controllers and count it. We subtract one (because arrays are 0 based), and another one to go back in history &#8211; hence we go &#8220;minus 2&#8243;. Then we pop to view controller just behind the current one.</p>
<p>Test if the returned value is less than zero though&#8230;</p>
<p>If you want to go back all the way to the root view controller, there&#8217;s a method for that:</p>
<pre class="wp-code-highlight prettyprint">
    // pop back to root controller
    [self.navigationController popToRootViewControllerAnimated:YES];
</pre>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/7fRzMDiW67c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-pop-a-uinavigationcontroller-in-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-pop-a-uinavigationcontroller-in-code/</feedburner:origLink></item>
		<item>
		<title>How to “quick save” in Core Data</title>
		<link>http://feedproxy.google.com/~r/wpguru-co-uk/~3/3AwtAVm8IIU/</link>
		<comments>http://wpguru.co.uk/2013/03/how-to-quick-save-in-core-data/#comments</comments>
		<pubDate>Mon, 04 Mar 2013 00:26:53 +0000</pubDate>
		<dc:creator>Jay Versluis</dc:creator>
				<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Core Data]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pinkstone.co.uk/how-to-save-in-core-data/</guid>
		<description><![CDATA[The easiest way to access a readily available save method is by importing AppDelegate into the class that wants to execute the save. Then we call a method in AppDelegate: AppDelegate *myAppDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate]; [myAppDelegate saveContext]; No reference to fetchedResultsController or managedObjectContext or any complex &#38;error statements.]]></description>
				<content:encoded><![CDATA[<p>The easiest way to access a readily available save method is by importing AppDelegate into the class that wants to execute the save. Then we call a method in AppDelegate:</p>
<pre class="wp-code-highlight prettyprint">
AppDelegate *myAppDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
[myAppDelegate saveContext];
</pre>
<p>No reference to fetchedResultsController or managedObjectContext or any complex &#038;error statements.</p>
<img src="http://feeds.feedburner.com/~r/wpguru-co-uk/~4/3AwtAVm8IIU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.uk/2013/03/how-to-quick-save-in-core-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://wpguru.co.uk/2013/03/how-to-quick-save-in-core-data/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 1.130 seconds. --><!-- Cached page generated by WP-Super-Cache on 2013-06-19 02:39:33 --><!-- Compression = gzip -->
