Tuesday, July 3, 2012

Dealing with Anxiety

An article i wrote a while back based on Pastor Don Green's sermon.
Hope it helps you to trust in God fully and take away the focus of your worries.

https://docs.google.com/open?id=0B3mFctiTYo5MeVVZclZETG9ZU0U

Monday, August 2, 2010

Learn English on the iPhone

Useful for your primary six niece, nephews, cousins, children to practise their English on the go!

Get the app here. https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/5.0.9.7.7.3.1.1.0.5.3.1.1

Sunday, July 25, 2010

Short post on navigating between views.

In this article, we will go through how to incorporate multiple views into our application. By default, creating a new View-based project in Xcode gives you a View. To create a second view, right click on classes, select Add new View class with xib file. That will give you a new ViewController class along with its xib file.

The below example code shows you how you can link your first view to your second view and back from second view to your first view. Remember to import the .h file of the View.

OctopusAnswer *octupusAnswer = [[OctopusAnswer alloc] initWithNibName:@"OctopusAnswer" bundle:nil];
[self.view addSubview:octupusAnswer.view];

octupusAnswer.answer.text = [tmpAns stringByAppendingString:@"!"];

// on the other form
[self.view removeFromSuperview];

Monday, July 19, 2010

I am on AppStore

Finally, my first app on AppStore. Check it out. 


Useful tool to use before deciding to buy that Punggol HDB flat or Weekend car


http://itunes.apple.com/sg/app/easy-loan-calculator/id381932538?mt=8


Sunday, July 18, 2010

Reading a Text File line by line and Tokenizing each line in Objective C

Here's a confirmed working code of how to read a file line by line and thereafter, tokenizing it. 


    NSString *path = [[NSBundle mainBundle] pathForResource:@"test2" ofType:@"txt"];
    NSString *string = [[NSString alloc] initWithContentsOfFile:path encoding:NSASCIIStringEncoding error:NULL];

    NSArray *lines = [string componentsSeparatedByString:@"\n"]; // each line, adjust character for line endings
    NSEnumerator *nse = [lines objectEnumerator];
    NSMutableArray *values = [NSMutableArray new];
    NSString *tmp;
    while(tmp = [nse nextObject])
    {
NSArray *chunks = [tmp componentsSeparatedByString: @","];
NSEnumerator *nse2 = [chunks objectEnumerator];

NSString *tmp2;
while(tmp2 = [nse2 nextObject]){
NSLog(@"%@",tmp2);
}
NSLog(@"%@", tmp);
    }

Thursday, July 15, 2010

Ask Octopus Paul

There was a recent rage over a Octopus called Paul. Now feel this rage over the iPhone. 
Lookout for the upcoming Ask the Octopus app! Free download. No superstition. Just for fine!

Using Two PickerViews together

Using two PickerViews together.

Expanding upon the previous tutorial, we will explore how to use two PickerViews together. Such is useful for ‘converter’ like applications, eg. currency converter, units converter.

Below figure shows an example of a bible units converter. that uses two PickerViews.

To have two PickerViews in your app, first drag and drop another PickerView into you xib file .. Declare the Outlet for it. Remember to click them to File’s owner.

The code where you have to edit are the below. Include an if-else condition based on the pickerView that triggered the method. I have two pickerViews, one named pickerView, the other pickerView2. Check which pickerView triggered the method, and set the corresponding label to the value of that particular pickerView.

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if([thePickerView isEqual:self.pickerView])
mlabel.text= [arrayNo objectAtIndex:row];
else
mlabel2.text= [arrayNo2 objectAtIndex:row];
}

Have a similar if-else condition to return the no. of rows in each PickerView and also the title for each pickerView cell.
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{
if([pickerView isEqual:self.pickerView])
return [arrayNo count];
else
return [arrayNo2 count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
if([pickerView isEqual:self.pickerView])
return [arrayNo objectAtIndex:row];
else
return [arrayNo2 objectAtIndex:row];
}

So there you go, how to use two picker Views together.