<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en">
    <title type="text">BigEvilEmpire: Code Log</title>
    <subtitle type="text">CodeLog:</subtitle>
    <link rel="alternate" type="text/html" href="http://www.bigevilempire.com/codelog/" />
    
    <updated>2009-04-17T09:46:59Z</updated>
    <rights>Copyright (c) 2009, BigEvilEmpire</rights>
    <generator uri="http://expressionengine.com/" version="1.6.8">ExpressionEngine</generator>
    <id>tag:bigevilempire.com,2009:03:20</id>

    <link rel="self" href="http://feeds.feedburner.com/bigevilempire/codelog" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry>
      <title>Configure MySQL for UTF-8</title>
      <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/bigevilempire/codelog/~3/jjbOgxUsY4Y/" />
      <id>tag:bigevilempire.com,2009:codelog/2.44</id>
      <published>2009-03-20T08:38:58Z</published>
      <updated>2009-04-17T09:46:59Z</updated>
      <author>
            <name>BigEvilEmpire</name>
                  </author>

      <category term="MySQL" scheme="http://www.bigevilempire.com/codelog/archives/category/mysql/" label="MySQL" />
      <content type="html">&lt;p&gt;Ever saved a record into a MySQL database and upon retrieval of the record, you realized that the non-Latin characters(e.g. Asian characters) don't quite turn up as expected? Specifically, they turn up as a bunch of "?".&lt;/p&gt;

&lt;p&gt;The likelihood of why this is occurring is that the MySQL database is configured as a default for Latin characters. In this day and age, one would assume that UTF-8 would be a de facto standard for this. Given my limited knowledge on database administration, I cannot fathom why Latin is chosen as a default over UTF-8. Shouldn't the benefit and the flexibility of supporting non-Latin characters outweigh whatever space that a Latin-only database saves (I am guessing this is the benefit) ?&lt;/p&gt;

&lt;p&gt;Oh well, what would I know.&lt;/p&gt;

&lt;p&gt;If UTF-8 is a foreign term, you absolutely need to read why it should even be a concern to any developer: &lt;a href="http://www.joelonsoftware.com/articles/Unicode.html" title="The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets"&gt;The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For those, who see the need to support UTF-8 in your MySQL databases, fortunately you can do so by editing the MySQL configuration file &amp;#40;my.cnf&amp;#41;. This file is typically found at: /etc/mysql/my.cnf if you are on Mac OS X or any UNIX/Linux-based OS.&lt;/p&gt;

&lt;p&gt;Add the following to the my.cnf:&lt;/p&gt;

&lt;pre class="code:bash"&gt;
[client]
default-character-set = utf8 
...
... 

[mysqld]
default-character-set = utf8 
character-set-server  = utf8
default-collation     = utf8_general_ci
...
&lt;/pre&gt;

&lt;p&gt;As an alternative, you can specify the default collation to be using "utf8_unicode_ci". The difference between them is :&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;For any Unicode character set, operations performed using the _general_ci collation are faster than those for the _unicode_ci collation. For example, comparisons for the utf8_general_ci  collation are faster, but slightly less correct, than comparisons for utf8_unicode_ci. The reason for this is that utf8_unicode_ci supports mappings such as expansions; that is, when one character compares as equal to combinations of other characters. For example, in German and some other languages “ß” is equal to “ss”. utf8_unicode_ci also supports contractions and ignorable characters. utf8_general_ci  is a legacy collation that does not support expansions, contractions, or ignorable characters. It can make only one-to-one comparisons between characters.&lt;/p&gt;&lt;/blockquote&gt; 

&lt;p&gt;For more information on configuration of character-set:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;a href="http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html" title="Conection Character Sets and Collations"&gt;Conection Character Sets and Collations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://dev.mysql.com/doc/refman/5.0/en/charset-unicode-sets.html" title="Unicode Character Sets"&gt;Unicode Character Sets&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/bigevilempire/codelog/~4/jjbOgxUsY4Y" height="1" width="1"/&gt;</content>
    <feedburner:origLink>http://www.bigevilempire.com/codelog/entry/configure-mysql-for-utf-8/</feedburner:origLink></entry>

    <entry>
      <title>Learning Ruby</title>
      <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/bigevilempire/codelog/~3/r4jvupD2t7I/" />
      <id>tag:bigevilempire.com,2009:codelog/2.42</id>
      <published>2009-03-09T00:21:09Z</published>
      <updated>2009-03-20T18:55:15Z</updated>
      <author>
            <name>BigEvilEmpire</name>
                  </author>

      <category term="Ruby" scheme="http://www.bigevilempire.com/codelog/archives/category/ruby/" label="Ruby" />
      <content type="html">&lt;p&gt;As I delved more into the world of the Ruby Programming language, I am discovering tools and resources that would be of help to someone new to Ruby. I want to log my learnings as I go along in hope that it would benefit anyone who might be trudging down this same path. &lt;/p&gt;

&lt;p&gt;I may have jumped the gun when I wrote about &lt;a href="http://www.bigevilempire.com/codelog/entry/using-ruby-modules/" title="using modules in Ruby"&gt;using modules in Ruby&lt;/a&gt;. To kick-start learning about Ruby, it might be prudent to understand about the syntax of Ruby. There are several gems (pun intended) available online that cover the basics of the Ruby language:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://en.wikibooks.org/wiki/Ruby_Programming" title="Wikibooks: Ruby Programming"&gt;Wikibooks: Ruby Programming&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.rubycentral.com/pickaxe" title="Programming Ruby"&gt;Programming Ruby&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://poignantguide.net/ruby/" title="Why's (Poignant) Guide to Ruby"&gt;Why's (Poignant) Guide to Ruby&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.cs.auckland.ac.nz/references/ruby/doc_bundle/Newcomers/ruby.html" title="Things That Newcomers to Ruby Should Know"&gt;Things That Newcomers to Ruby Should Know&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In addition to these guides, there are also tools which are pretty handy for Ruby. For some quick action and experimentations with Ruby, there is always the &lt;a href="http://en.wikipedia.org/wiki/Interactive_Ruby_Shell" title="Interactive Ruby Shell"&gt;Interactive Ruby Shell&lt;/a&gt; (commonly referred to as IRB). To use the IRB, just launch the Terminal app in Mac OS X and type "irb". Within the IRB, you will be able to enter Ruby commands and have the interpreter respond immediately.&lt;/p&gt;

&lt;pre class="code:ruby"&gt;
$ irb

irb(main):001:0&gt; myArray = [1,2,3,4,5]
=&gt; [1, 2, 3, 4, 5]
irb(main):002:0&gt; myArray.each do |x|
irb(main):003:1* puts x
irb(main):004:1&gt; end
1
2
3
4
5
=&gt; [1, 2, 3, 4, 5]
irb(main):005:0&gt;
&lt;/pre&gt;

&lt;p&gt;For quick-access to view Ruby documentation off-line, you can always fall back on the ri documentation viewer. Launch the Terminal app in Mac OS X and invoke "ri" followed by the name of a Ruby class, module or method and ri will pull up the documentation accordingly.&lt;/p&gt;

&lt;p&gt;Here are some sample usage of ri:&lt;/p&gt;

&lt;pre class="code:bash"&gt;
ri Array
ri 'Array#&amp;lt;&amp;lt;'
ri Array.each
ri Array::new
&lt;/pre&gt;

&lt;p&gt;For any initiate to Ruby, these should be more than enough to get u moving along. Happy learning.&lt;/p&gt;

&lt;img src="http://feeds.feedburner.com/~r/bigevilempire/codelog/~4/r4jvupD2t7I" height="1" width="1"/&gt;</content>
    <feedburner:origLink>http://www.bigevilempire.com/codelog/entry/learning-ruby/</feedburner:origLink></entry>

    <entry>
      <title>Using Ruby Modules</title>
      <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/bigevilempire/codelog/~3/A4tKKNfmMsI/" />
      <id>tag:bigevilempire.com,2009:codelog/2.41</id>
      <published>2009-03-03T08:15:29Z</published>
      <updated>2009-03-20T18:43:18Z</updated>
      <author>
            <name>BigEvilEmpire</name>
                  </author>

      <category term="Ruby" scheme="http://www.bigevilempire.com/codelog/archives/category/ruby/" label="Ruby" />
      <content type="html">&lt;p&gt;In my recent pursue of learning &lt;a href="http://rubyonrails.org/" title="Rails"&gt;Rails&lt;/a&gt;, I have gotten more exposure to the Ruby. The Ruby programming language is very pretty in terms of its syntax and the semantics. It is object-oriented and allow classes to import modules as mixins, which is the subject of this post.&lt;/p&gt;

&lt;p&gt;I am still very new to Ruby and pretty much learning as I go along. This post is more to document my own learning than anything. &lt;/p&gt;


&lt;pre class="code:ruby"&gt;
module MySharedModule
  HASH_CONSTANT = &amp;#123;:mykey =&gt; "value of mykey"&amp;#125;
  
  def mixin_method
    puts "calling mixin method"
  end
    
  class ClassInModule
    def self.class_method
      puts "calling class method"
    end
    
    def instance_method
      puts "calling instance_method"
    end
  end
end


class MyClass
  include MySharedModule
  
  def initialize
    # access module's constant
    # to be more verbose: MySharedModule::HASH_CONSTANT 
    puts HASH_CONSTANT[:mykey]    
    
    # access module method
    mixin_method
        
    # calls class method of a class in module
    # to be more verbose: MySharedModule::ClassInModule.class_method
    ClassInModule.class_method
        
    # instantiate, call instance method of class in module
    # to be more verbose: MySharedModule::ClassInModule.class_method
    instance = ClassInModule.new
    instance.instance_method    
  end
end


myClass = MyClass.new



# Output:
# value of mykey
# calling mixin method
# calling class method
# calling instance_method
&lt;/pre&gt;


&lt;p&gt;To learn more about using modules in Ruby:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://www.rubyfleebie.com/an-introduction-to-modules-part-1/" title="Ruby Fleebie: An introduction to modules"&gt;Ruby Fleebie: An introduction to modules&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.juixe.com/techknow/index.php/2006/06/15/mixins-in-ruby/" title="Juixe TechKnow: Ruby Mixin Tutorial"&gt;Juixe TechKnow: Ruby Mixin Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/bigevilempire/codelog/~4/A4tKKNfmMsI" height="1" width="1"/&gt;</content>
    <feedburner:origLink>http://www.bigevilempire.com/codelog/entry/using-ruby-modules/</feedburner:origLink></entry>

    <entry>
      <title>Bash Completion For Git</title>
      <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/bigevilempire/codelog/~3/yCR8uVybi-s/" />
      <id>tag:bigevilempire.com,2009:codelog/2.39</id>
      <published>2009-01-15T07:10:23Z</published>
      <updated>2009-01-16T16:23:23Z</updated>
      <author>
            <name>BigEvilEmpire</name>
                  </author>

      <category term="Mac" scheme="http://www.bigevilempire.com/codelog/archives/category/mac/" label="Mac" />
      <content type="html">&lt;p&gt;Bash completion for Git is a very handy utility for a Git and &lt;a href="http://www.gnu.org/software/bash/" title="Bash"&gt;Bash&lt;/a&gt; user. For the past few months, I have been trying out Git for source control. Having Bash completion for Git was useful in my attempts to get acquainted with the commands. So what exactly is Bash completion for Git?&lt;/p&gt;

&lt;p&gt;If you are on Mac OS X, Bash comes with command completion. After typing part of a filename, command or pathname in Bash, hitting the &amp;lt;TAB&amp;gt; key will trigger Bash to prompt you with either the remaining portion of the filename or path. A subsequent &amp;lt;TAB&amp;gt; will then trigger a list of filenames or path that matches what has been keyed in so far.&lt;/p&gt;

&lt;p&gt;Bash completion for Git works the same way by prompting you with available commands or filename.&lt;/p&gt;

&lt;p&gt;One possible installation method would be using &lt;a href="http://www.macports.org/" title="MacPorts"&gt;MacPorts&lt;/a&gt;. MacPorts is a really useful tool for compiling, installing and upgrading open-source software on the Mac OS X. It is command-line driven and is relatively simple to use.&lt;/p&gt;

&lt;pre class="code:bash"&gt;
sudo port install -u git-core +bash_completion +doc +svn
&lt;/pre&gt;

&lt;p&gt;The command above installs Git with variants (variants are essentially additional options). In this case, MacPorts is installing Git with SVN, Git Man files (documentatons) and the main subject of our interest: Bash completion itself.&lt;/p&gt;

&lt;p&gt;When installing new version of a port, MacPorts will make the existing version inactive and then install the latest version. Over time, you can wind up with a lot of inactive version for a port. The -u flag simply instructs MacPorts to uninstall any inactive ports.&lt;/p&gt;

&lt;p&gt;The last step to this is to edit the user Bash configuration file in your home folder (~/.bash_profile) or the system-wide one (/etc/profile) and insert in the following:&lt;/p&gt;

&lt;pre class="code:bash"&gt;
if [ -f /opt/local/etc/bash_completion ]; then
  . /opt/local/etc/bash_completion
  export PS1='\h:\W$(__git_ps1 "(%s)") \u\$ '
fi
&lt;/pre&gt;

&lt;p&gt;Apart from checking if the bash completion script exists and running it, the code above will also modify the Bash prompt so that you can always tell which Git branch you are currently working on. Handy information to have at the Bash prompt.&lt;/p&gt;

&lt;p&gt;And it is done, Git for source control with extra help from Bash completion.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/bigevilempire/codelog/~4/yCR8uVybi-s" height="1" width="1"/&gt;</content>
    <feedburner:origLink>http://www.bigevilempire.com/codelog/entry/bash-completion-for-git/</feedburner:origLink></entry>

    <entry>
      <title>NSURLConnection With gzip</title>
      <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/bigevilempire/codelog/~3/0z9FR2Ob5n0/" />
      <id>tag:bigevilempire.com,2008:codelog/2.37</id>
      <published>2008-10-20T00:04:32Z</published>
      <updated>2009-03-27T05:49:33Z</updated>
      <author>
            <name>BigEvilEmpire</name>
                  </author>

      <category term="Cocoa" scheme="http://www.bigevilempire.com/codelog/archives/category/cocoa/" label="Cocoa" />
      <category term="Cocoa Touch" scheme="http://www.bigevilempire.com/codelog/archives/category/cocoa-touch/" label="Cocoa Touch" />
      <category term="Objective-C" scheme="http://www.bigevilempire.com/codelog/archives/category/objective-c/" label="Objective-C" />
      <content type="html">&lt;p&gt;It is nice to know that the NSURLConnection class supports &lt;acronym title="GNU zip"&gt;gzip&lt;/acronym&gt; out of the box. The NSURLConnection class also does auto-decoding of the compressed data when the compressed content is received. However, by default even though the NSURLConnection class is handling this, it does not automatically add the required header to the HTTP request.&lt;/p&gt;

&lt;p&gt;In order to inform the web server that the client is compression-aware and prefer to receive gzip-compressed content, you need to manually add the header to the HTTP request:&lt;/p&gt;

&lt;pre class="code:ObjC"&gt;
NSURL *url = [NSURL URLWithString:@"http://www.fubar.com/webservice.xml"];
NSMutableURLRequest* urlReq = [[NSMutableURLRequest alloc] initWithURL:url];

//add gzip-encoding to HTTP header
[urlReq setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
&lt;/pre&gt;

&lt;p&gt;If the web server supports gzip compression, the response that it returns to your Cocoa application or iPhone app will be compressed.&lt;/p&gt;

&lt;p&gt;By utilizing gzip-compressed content, it reduces response time for a HTTP response because the size of the HTTP response is smaller. This may have a considerable impact to native iPhone apps that rely heavily on web services since the overall network traffic is optimized and data transfer is more responsive. &lt;/p&gt;

&lt;p&gt;For those new to gzip compression, BetterExplained has a very good article explaining &lt;a href="http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/" title="How To Optimize Your Site With gzip Compression"&gt;how gzip help in site optimization&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/bigevilempire/codelog/~4/0z9FR2Ob5n0" height="1" width="1"/&gt;</content>
    <feedburner:origLink>http://www.bigevilempire.com/codelog/entry/nsurlconnection-with-gzip/</feedburner:origLink></entry>

    <entry>
      <title>Creating iPhone App Without XIB</title>
      <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/bigevilempire/codelog/~3/Cvfu6dGtG68/" />
      <id>tag:bigevilempire.com,2008:codelog/2.36</id>
      <published>2008-10-17T05:15:16Z</published>
      <updated>2008-10-20T00:59:16Z</updated>
      <author>
            <name>BigEvilEmpire</name>
                  </author>

      <category term="Cocoa" scheme="http://www.bigevilempire.com/codelog/archives/category/cocoa/" label="Cocoa" />
      <category term="Cocoa Touch" scheme="http://www.bigevilempire.com/codelog/archives/category/cocoa-touch/" label="Cocoa Touch" />
      <content type="html">&lt;p&gt;The XIB file format is introduced in the Interface Builder 3 on Leopard. It replaces the previous file format NIB, short for NeXT Interface Builder. The Interface Builder application is a GUI for building and assembling user-interface objects, images and references to sounds for your Mac application. It allows you to drag and drop user-interface objects such as buttons, tableviews onto a window and layout the objects visually. These objects are archived and saved as a XIB file. When an application launches, these XIB files are loaded and un-archived. The user-interface objects are then made available to the application.&lt;/p&gt;

&lt;p&gt;For those who are keen to know more about the inner workings of XIB files, I would recommend checking out Fraser Speirs' post on&lt;a href="http://speirs.org/2007/12/05/what-are-xib-files/" title="What are XIB files?"&gt; XIB files&lt;/a&gt;.&lt;/p&gt; 

&lt;p&gt;Using the Interface Builder is a convenient way to handle views hierachy and user-interface objects but however, you can also opt to handle these programmatically. To do that, create a new Project in XCode and use the "Window Based Application" template. This template is the basic and simplest template and it is ideal for this purpose.&lt;/p&gt;

&lt;p&gt;The template provides the MainWindow.xib file which is unnecessary since we are programatically creating the user-interface objects. You can delete it and also remove the reference to this XIB file by deleting the last entry "Main nib file base name" in the Info.plist file.&lt;/p&gt;

&lt;p&gt;You would then edit the main.m file as shown below:&lt;/p&gt;

&lt;pre class="code:ObjC"&gt;
int main(int argc, char *argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal= UIApplicationMain(argc,argv,@"UIApplication",@"AppDelegate");
    [pool release];
    return retVal;
}
&lt;/pre&gt;

&lt;p&gt;The main.m file, as the name suggests, contains the code that will run when the application gets launched. By editing the main.m file as shown, the code will create an instance of a UIApplication class named "AppDelegate".&lt;/p&gt;

&lt;p&gt;The last step to this would be to set up the AppDelegate class: &lt;/p&gt;

&lt;pre class="code:ObjC"&gt;
#import "AppDelegate.h"

@implementation AppDelegate

@synthesize window;

-(void)applicationDidFinishLaunching:(UIApplication *)application {
	window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
	window.backgroundColor = [UIColor whiteColor];

    // Override point for customization after application launch
    [window makeKeyAndVisible];
}


-(void)dealloc {
    [window release];
    [super dealloc];
}

@end
&lt;/pre&gt;


&lt;p&gt;All that the AppDelegate class does is to create the main window of the application and make it visible. Voila! Now you are all set to go! A basic iPhone App without any XIB file.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/bigevilempire/codelog/~4/Cvfu6dGtG68" height="1" width="1"/&gt;</content>
    <feedburner:origLink>http://www.bigevilempire.com/codelog/entry/creating-iphone-app-without-xib/</feedburner:origLink></entry>

    <entry>
      <title>Private Methods In Objective-C</title>
      <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/bigevilempire/codelog/~3/kMExproT53s/" />
      <id>tag:bigevilempire.com,2008:codelog/2.35</id>
      <published>2008-10-03T06:50:45Z</published>
      <updated>2008-10-13T05:45:44Z</updated>
      <author>
            <name>BigEvilEmpire</name>
                  </author>

      <category term="Objective-C" scheme="http://www.bigevilempire.com/codelog/archives/category/objective-c/" label="Objective-C" />
      <content type="html">&lt;p&gt;Even though Objective-C has support for private, protected and public instance variables, there is no notion of private methods. Every method is considered as public. However, there is an easy approach to make mock private methods by using categories.&lt;/p&gt;


&lt;pre class="code:ObjC"&gt;
//--------------------------------------------
// File: SomeClass.h
//--------------------------------------------

@interface SomeClass
+ (void)publicClassMethod;
- (void)publicInstanceMethod;
@end
&lt;/pre&gt;

&lt;p&gt;The interface definition would be the same; just declaring the public methods available (as shown above). However for the implementation of the class, an additional definition for the category would be required and the implementation for the private method will follow after the usual implementation for the class.&lt;/p&gt; 


&lt;pre class="code:ObjC"&gt;
//--------------------------------------------
// File: SomeClass.m
//--------------------------------------------

@interface SomeClass (Private)
+ (void)hiddenClassMethod;
- (void)hiddenInstanceMethod;
@end


@implementation SomeClass
+ (void)publicClassMethod{
	//This class method is public
};

- (void)publicInstanceMethod
	//This instance method is public
}
@end


@implementation SomeClass (Private)
+ (void)hiddenClassMethod{
  //This class method is private
}

- (void)hiddenInstanceMethod{
  //This instance method is private
}
@end

&lt;/pre&gt;

&lt;p&gt;To avoid writing a separate @implementation block for the private method, we can use "anonymous" categories. This is done and demonstrated below by omitting a name in the parentheses of the second @interface block.&lt;/p&gt;

&lt;pre class="code:ObjC"&gt;
//--------------------------------------------
// File: SomeClass.m
//--------------------------------------------

@interface SomeClass ()			//name is omitted for the category
+ (void)hiddenClassMethod;
- (void)hiddenInstanceMethod;
@end


@implementation SomeClass
+ (void)publicClassMethod{
	//This class method is public
};

- (void)publicInstanceMethod
	//This instance method is public

+ (void)hiddenClassMethod{
  //This class method is private
}

- (void)hiddenInstanceMethod{
  //This instance method is private
}

@end

&lt;/pre&gt;


&lt;p&gt;Despite all these, one thing to be mindful of is that there are no true private methods in Objective-C. These mock private methods will still be available during run-time. The documented use of &lt;a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_1.html#//apple_ref/doc/uid/TP30001163-CH20-SW1" title="categories"&gt;categories&lt;/a&gt; is to add methods to an existing class without requiring the actual source. It enables the functionality of the class to be extended without sub-classing.&lt;/p&gt; &lt;img src="http://feeds.feedburner.com/~r/bigevilempire/codelog/~4/kMExproT53s" height="1" width="1"/&gt;</content>
    <feedburner:origLink>http://www.bigevilempire.com/codelog/entry/private-methods-in-objective-c/</feedburner:origLink></entry>

    <entry>
      <title>Hiding Folders From The Finder</title>
      <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/bigevilempire/codelog/~3/B4w_e01whrM/" />
      <id>tag:bigevilempire.com,2008:codelog/2.32</id>
      <published>2008-09-23T08:03:39Z</published>
      <updated>2008-09-25T19:29:39Z</updated>
      <author>
            <name>BigEvilEmpire</name>
                  </author>

      <category term="Mac" scheme="http://www.bigevilempire.com/codelog/archives/category/mac/" label="Mac" />
      <content type="html">&lt;p&gt;Mac OS X is a Unix-based operating system and because of that, it comes with a directory structure that is similar to the Unix operating system. What this means is that you will have directories like "etc", "var", "usr" etc. at your root. At this point some of you may think I am sprouting nonsense. Those directories do not even appear in the Finder. What am I talking about?!&lt;/p&gt;

&lt;p&gt;Well, here is the thing. Those directories do exist but however, they do not appear in the Finder and are well hidden away from the UI of the Mac OS X. These directories contain important files for the OS and the average user would never have the need to mess with the content inside them.&lt;/p&gt;

&lt;p&gt;I use &lt;a href="http://www.macports.org/" title="MacPorts"&gt;MacPorts&lt;/a&gt; to manage my command-line open-source software on my Mac. By default, MacPorts installs the software to the directory "/opt/local". It creates a directory "opt" and that directory appears in the Finder. Thankfully there is a way to hide this directory from the Finder like the ones mentioned earlier.&lt;/p&gt;

&lt;p&gt;There are two useful tools that comes with the Developer Tools: &lt;a href="http://devworld.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man1/GetFileInfo.1.html" title="GetFileInfo"&gt;GetFileInfo&lt;/a&gt; and &lt;a href="http://devworld.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man1/SetFile.1.html" title="SetFile"&gt;SetFile&lt;/a&gt;. They can be found in this directory: /Developer/Tools/&lt;/p&gt;

&lt;p&gt;To hide any directory (in this case, the "opt" directory) from the Finder, run the following command in Terminal:&lt;/p&gt;

&lt;pre class="code:bash"&gt;
sudo SetFile -a V /opt
&lt;/pre&gt;

&lt;p&gt;To view the file attributes of a file or directory, run the following command:&lt;/p&gt;


&lt;pre class="code:bash"&gt;
GetFileInfo /opt
&lt;/pre&gt;

&lt;p&gt;In this example, you can see that the directory "/opt" has an uppercase "V" in its attributes. This flag indicates that the directory is to be hidden from the Finder.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/bigevilempire/codelog/~4/B4w_e01whrM" height="1" width="1"/&gt;</content>
    <feedburner:origLink>http://www.bigevilempire.com/codelog/entry/hiding-folders-from-the-finder/</feedburner:origLink></entry>

</feed>
