isEqualToString: method should be used to compare values of the string objects.

if([myString isEqualToString:@"1"] || [myString isEqualToString:@"2"] || [myString isEqualToString:@"3"])
action = @”showDifferences”;

If you use the == operator on strings, you are comparing the strings’ addresses (allocated memory) rather than the values of the string objects.

if(myString==@”1″ || myString ==@”2″ || myString ==@”3″)
action = @”showDifferences”;

This is a simple approach to draw a UITextView, insert content from a text file within Xcode project, disable editing, and customize font style during loading app.

- (void)viewDidLoad {

[super viewDidLoad];
CGRect viewRect = CGRectMake(0.0, 0.0, 320.0, 420.0);
myTextView = [[UITextView alloc] initWithFrame:viewRect];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filename = [documentsDirectory stringByAppendingPathComponent:@"sample.txt"];
NSString *filenameString = [NSString stringWithContentsOfFile:filename];
myTextView.text = filenameString;
myTextView.editable = NO;
myTextView.textAlignment = UITextAlignmentCenter;
UIFont *myFont = [UIFont fontWithName:@"Helvetica" size:10.0];
// add Font color
myTextView.font = myFont;
[self.view addSubview:myTextView];
}

Method 1:
// Declare URL parameters
NSString *URL = @”http://www.xyz.com/api?”;
NSString *latitudeURL = @”latitude=”;
NSString *longitudeURL = @”&longitude=”;
NSString *altitudeURL = @”&altitude=”;
// Concatenate all the strings
NSString *entireURL = [NSString stringWithFormat:@"%@%@%@%@%@%@%@", URL, latitudeURL, latitudeString, longitudeURL, longitudeString, altitudeURL, altitudeString];
NSLog(@”show:%@”, entireURL);

Method 2:

// Shortcut to concatenate all the strings
NSString *apiString = [NSString stringWithFormat:@"http://www.xyz.com/api?latitude=%@&longitude=%@&altitude=%@", latitudeString, longitudeString, altitudeString];
NSLog(@”show:%@”, apiString);

UIDevice *device = [UIDevice currentDevice];
NSString *uniqueIdentifier = [device uniqueIdentifier];
[device release];
NSLog(@”Device GUID: %@”, uniqueIdentifier);

Method 1: Add two strings together by using stringByAppendingString: method

NSString *string1 = @”Hello”;
NSString *string2 = @”World”;
NSString *entireString;
entireString = [string1 stringByAppendingString:string2];

Method 2:

NSString *string1 = @”This”;
NSString *string2 = @”is”;
NSString *string3 = @”a”;
NSString *string4 = @”test”;
NSString *entireString = [NSString stringWithFormat:@"%@ %@ %@ %@", string1, string2, string3, string4];

I painfully discover there are many outdated blog tutorials on installing mysql. It is difficult to find the most accurate documentation even within the official mysql.com website.

Outdated command
$sudo port install mysql5 +server

If you did make a mistakes, uninstall mysql5 +server.

$ port uninstall mysql +server

The mysql5 +server package variant in MacPorts is obsolete, and is superseded by the mysql5-server package, which you install in addition to mysql5. This allows you to build it after the fact, instead of re-compiling the entire mysql5 package with +server.

Install both mysql5 and mysql5-server packages. You should find mysql5 plist file in /Library/LaunchDaemons. You should not need to symlink your mysqld.sock to /tmp/mysql.sock.

# Install MySQL
sudo port install mysql5 mysql5-server
sudo -u mysql mysql_install_db5
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
sudo port install rb-mysql
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'PASSWORD'
sudo gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5
# Install Apache
sudo port install apache2
sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
sudo /opt/local/apache2/bin/apachectl -k start
sudo /opt/local/apache2/bin/apachectl -k stop
# Install Passenger
sudo gem install passenger
sudo passenger-install-apache2-module
# Extras
sudo port install wget
sudo port install ImageMagick
sudo port install sphinx
sudo gem install capistrano

These are the common macport commands on mac OSX to install, uninstall and upgrade packages such as php, python, ruby, mysql, sqlite, rails, django, etc.

sudo port install packagename
sudo port uninstall packagename
sudo port upgrade packagename

To see the latest installed version using macport

port installed

To install Version Control Git with SVC, you update macport first.

sudo port selfupdate

Then you install Git

# Install Subversion
sudo port install subversion

# Install Git
sudo port install git-core +svn
sudo gem install git

Customize Terminal

November 7, 2009

To resolve the profile on terminal consider doing this using nano as editor on your OSX Terminal.

To open ~/.bash_profile in nano

$ nano ~/.bash_profile

Enter the following. Save the file by Ctl+o and exit nano by Ctl+x

. ~/.bashrc
ENV=$HOME/.bashrc
export ENV

Save all the settings in .bashrc to avoid duplication

Customize the terminal promot. Enter the following in .bashrc using nano

export PS1=”\u$ “

This will show username with $ as terminal prompt

Nokia Mobile HTML Templates

November 2, 2009

Nokia just open source their mobile HTML templates for high-end, mid-range, and low-end phones. It includes templates and layout samples with content.

It includes HTML, CSS, Photoshop & Illustrator templates. It is a good starting point for Nokia beginner developers.

The high-end templates include components optimised for touch devices (S60 5th Edition and Maemo), and components optimised for Series 40 and S60 WebKit non-touch devices.

The mid-range templates include pre-styled mobile web elements optimised for a large collection of Series 40 devices from Series 40 3rd to Series 40 6th Edition.

The low-end templates include pre-styled mobile web elements optimised for a large collection of early S60 and Series 40 devices.

Nokia supported 94 Nokia phone models

Flash Lite 3.0 = 22 models
Flash Lite 2.1 = 21 models
Flash Lite 2.0 = 21 models
Flash Lite 1.1 = 30 models

S60 Platform (49 models)

Symbian S60 5th Edition
5800 XpressMusic
Flash Lite version: 3.0
Standalone: Player 360×640
Screensaver: 360×640
Wallpaper: No

Symbian S60 3rd Edition Feature Pack 2
9 models

  • 5320 XpressMusic
  • 6210 Navigator
  • 6220 classic
  • 6650
  • N78
  • N79
  • N85
  • N96
  • N96-3 NAM

Flash Lite version: 3.0 or 2.1
Standalone Player: 240×320
Screensaver: 240×320
Wallpaper: no

Symbian S60 3rd Edition Feature Pack 1
18 models

  • 5700
  • 6110 Navigator
  • 6120 classic
  • 6121 classic
  • 6124 classic
  • 6290
  • E51
  • E66
  • E71
  • E90
  • N76
  • N81
  • N81 8GB
  • N82
  • N95
  • N95-3 NAM
  • N95 8GB
  • N95-3 8GB NAM

Flash Lite version: 2.0
Standalone Player: 240×320
Screensaver: 240×320
Wallpaper: no

Symbian S60 3rd Edition
21 models

  • 3250
  • 5500 Sport
  • E50
  • E60
  • E61
  • E61i
  • E62
  • E65
  • E70
  • N71
  • N73
  • N73 Music Edition
  • N75
  • N77
  • N80
  • N80 IE
  • N91
  • N91 8GB
  • N92
  • N93
  • N93i

Flash Lite version: 1.1
Standalone Player: 240×320, 176×208, 208×208, 352×416, 352×416
Screensaver: No
Wallpaper: no