Friday 6 January 2012

Balance Guide v1.6 iPhone App

What's new in the latest version of Balance Guide ?

The multi-account feature has been extended further and now includes transfers between accounts. To provide maximum flexibly, the transfer feature allows you enter a different description and date, catering for differences in clearing.

Also a backup and restore feature via Dropbox

Balance Guide iPhone app

Saturday 23 October 2010

Whether to write standard code or re-write and learn code?

When I started developing for the iphone I had to make some decisions about how to structure code. I was face with a dilemma. Do I write code which I'll use often or do I reuse code.

I came to the decision to write code as I needed it, so that I'd learn and remember it. I spoke to friends at the time and this was the decision I arrived at.

Previously I'd always written standard functions and never remember how to code these requirements afterwards.

I've made the wrong decision.

I end up with more lines of code and code which I can never remember anyway. So the answer to write standard functions.

by JM

Wednesday 29 September 2010

iPhone, why I moved from FMDB to direct Sqlite3

I'm still quite disappointed, FMDB was easy to implement and only a few lines of code to do almost anything. I've even posted some example code on my blog. But when I sat and thought about, I realised I'd wasted two days (in total) trying figure out why sql wasn't working.

There must be some problems in the libraries as the sql was working but failed on simple sql statements.

So today I've decided to use Sqlite3 directly, which has taken me have a day and I have all the previous code replaced and working. Yes, it takes more code and is more difficult to implement.

by JM

Monday 27 September 2010

iPhone, how to insert a record using fmdb

One of the easiest ways to perform transactions with a database with the iPhone is with the fmdb libraries. Its a few lines of code to do almost anything.

This is the primary documentation for fmdb http://gusmueller.com/blog/archives/2005/3/22.html

It's pretty good and straight forward. But, I've had some problems today trying to insert a record. None of the usage code I found on the web seemed to be any different to the code I was using.

However, after inserting one field at a time I found my problem was due to using an integer where I needed to use NSNumber. So I thought I'd post the code I arrived at, maybe it will help someone else.






NSMutableString *strAmount = [NSMutableString stringWithString:txtAmount.text];
[strAmount replaceCharactersInRange: [strAmount rangeOfString: strCurrencySymbol]  withString:@""];
NSString *strRecurrance = [self.pickerRecurranceData objectAtIndex:intSelRecurrenceRow];
NSArray *parts = [strRecurrance componentsSeparatedByString: @" "];

NSNumber *numInterval = [NSNumber numberWithInt:[[parts objectAtIndex:0] intValue]];
NSString *strIntervalType = [parts objectAtIndex:1];

// string to date
NSString *myDateString = btnStartDate.titleLabel.text;
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"dd MM yyyy"];
NSDate *datStartDate = [[NSDate alloc] init];
datStartDate = [dateFormatter dateFromString:myDateString];

NSString *strDesc = txtDescription.text;


FMDatabase* db = [FMDatabase databaseWithPath:@"/tmp/tmp.db"];
if (![db open]) {
NSLog(@"Could not open db.");
}

if (![db tableExists:@"mytable"]) {
[db executeUpdate:@"CREATE TABLE 'mytable' ('pid' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,'desc' VARCHAR,'sdate' DATETIME,'interval' INTEGER,'itype' VARCHAR,'price' DOUBLE);", nil];
}

[db beginTransaction];


[db executeUpdate:@"INSERT INTO mytable (desc,sdate,interval,itype,price) VALUES (?,?,?,?,?);",
strDesc, datStartDate, numInterval, strIntervalType, strAmount, nil];

//NSLog(@"Err %d: %@", [db lastErrorCode], [db lastErrorMessage]);

[db commit];
[db close];

by JM

Thursday 23 September 2010

How to add a decimal point or a done button to the iphone number pad

Following on from our blog post about how to add the done button to the iphone number pad, here's how upgrade that code to add a decimal point as well, well not at the same time :)

How to add your own Done button to the iPhone numeric keypad



Ok, first of all if you haven't done so already, get the code working posted in the done blog post.

Now open up your NumberKeypadModController.h file and add the following to the top of the file below your foundation import.






#define KeyPadTypeDoneButton 1
#define KeyPadTypeDecimalPoint 2

Add this to the interface.






int intKeyPadType;

And this under properties






- (void)setKeyPadType:(int)value;
-(id)initWithKeyPadType: (int)value;

Now open your NumberKeypadModController.m file and add.






-(id)initWithKeyPadType: (int)value
{
[self setKeyPadType:value];
//self = [super init];
self = [self init];
if( self != nil ){
//self.intKeyPadType = value;

}
return self;

}

- (void)setKeyPadType:(int)value {
intKeyPadType = value;
NSLog(@"key=%i", intKeyPadType);
}

Now where you see the line containing @"Done", replace that with ..






if (intKeyPadType == KeyPadTypeDecimalPoint ) {
doneButton.titleLabel.font = [UIFont systemFontOfSize:35];
[doneButton setTitle:@"." forState:UIControlStateNormal];
} else if (intKeyPadType == KeyPadTypeDoneButton ) {
doneButton.titleLabel.font = [UIFont boldSystemFontOfSize:18];
[doneButton setTitle:@"DONE" forState:UIControlStateNormal];
}

Also replace the following functions






- (void)textFieldShouldEndEditing:(UITextField *)textField {
if (textField.keyboardType != UIKeyboardTypeNumberPad)
{
doneButtonShownRecently = YES;
if (intKeyPadType == KeyPadTypeDoneButton ) {
[self performSelector:@selector(considerDoneButtonReallyHidden) withObject:nil afterDelay:SLIDE_OUT_ANIMATION_DURATION];
}
return;
}
[self removeDoneFromKeyboard];
}- (void) donePressed {

if (intKeyPadType == KeyPadTypeDecimalPoint ) {
NSString *currentText = currentTextField.text;
if ([currentText rangeOfString:@"." options:NSBackwardsSearch].length == 0) {
currentTextField.text = [currentTextField.text stringByAppendingString:@"."];
}else {
//alreay has a decimal point
}
} else if (intKeyPadType == KeyPadTypeDoneButton ) {
[self.currentTextField resignFirstResponder];
}
if ([delegate respondsToSelector:@selector(donePressed:)])
[delegate performSelector:@selector(donePressed:) withObject:self.currentTextField];
}

At this point, I'd like to cite and give credit to DevUp for the decimal point formatting code in the donePressed function above.
http://blog.devedup.com/index.php/2010/03/13/iphone-number-pad-with-a-decimal-point/

Now in you useage code replace the following code..






int intCurrentKeyPad;- (void)viewDidLoad {
[super viewDidLoad];
//intCurrentKeyPad = KeyPadTypeDoneButton;
intCurrentKeyPad = KeyPadTypeDecimalPoint;

self.numberKeyPadModController = [[[NumberKeypadModController alloc] initWithKeyPadType:intCurrentKeyPad] autorelease];
//self.numberKeyPadModController = [[[NumberKeypadModController alloc] init] autorelease];
numberKeyPadModController.delegate = self;

[numberKeyPadModController setKeyPadType:intCurrentKeyPad];

if (intCurrentKeyPad == KeyPadTypeDoneButton ) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(doneButton:) name:@"DoneButtonPressed" object:nil];
}

textFieldRow1.delegate = self;
}

- (void)doneButtonPressed:(UITextField*)sender{
if (intCurrentKeyPad == KeyPadTypeDoneButton ) {
if ([textFieldRow1 isEditing]) {
[textFieldRow1 resignFirstResponder];
}
}
}

- (void) donePressed:(id)sender {
if (intCurrentKeyPad == KeyPadTypeDoneButton ) {
UIView* firstResponder = [self.view findFirstResponder];
[firstResponder resignFirstResponder];
}
}

Ok I hope this helps you out!

Feel free to make a comment about this article, let me know if you have any problems with it.

by Jules.

Thursday 27 May 2010

iPhone app description on iTunes observations #iphonedev

I'm at the stage with my app development where I've looking at writing a description for my app which will appear on iTunes. I thought it would be a good idea to have a look at my nearest competition and I thought I'd also look to see what blue had written.

Before I start, I'd just like to summarize my beliefs and expectations on what I think I'll find. As with any sales copy I know you have to sell benefit not features first, then go into the features. Also being iTunes you have to take into account how people will look at your description and how long they will spend looking.  So app icon / logo and screen shots are very important. I'm wondering if a lot of text is a good idea.

OK, I printed out some descriptions, I noticed that there's two different description, one for the US and one for GB, so I'm guessing you must be able to write a different description for each country / language.

I've only found the GB description for Blues app, I think he just sells to the UK not the US. Oddly his price appears in dollars. Whereas the others I have printed are in pounds or dollars, for the respect description country pages.

Blues opening line sells the benefits of the app, he then talks about the features and how to use the app for three paragraphs. Oh at this point, he and there other printouts, have a more link, which makes the screen shots more visible and stops people having the read too much if they just want to glance at the page, good idea.

On paragraph five through seven he talks about the benefits, I think I'd have put this at the start, then he has a sentence about user comments, showing that he's going to be around in the future to produce an update.

Unlike my other printouts, blue doesn't have any customer reviews, which are shown at the bottom of the page.

Printouts 2 and 3, US and GB. Heres, we have a line about the features then some feature bullet points and then a link to a video. This sounds like a good idea in principle, but what if they look at the video and then decide not to download the app, hmmm.  I think with it being so little effort to install an app it would be easier to do that. But I guess it would cost you to install. Hmmm, not sure on this one, I guess a video might be a good idea.

We've then got several meaty paragraphs (much more than blue wrote) , one for each screen in the app.

We then have a short list of one line reviews, which look good. I think this guy should have put his benefits up front and then the reviews, then gone into the functionality, I'm not so sure providing lots of text is such a good idea. However, you do have the more link after the first paragraph, so I guess you do have the option not to read.

Having said that people do like to read the description, especially when it may stop them wasting their money. My gut feeling is that having them read too much, when they could try the app instead, is a bad idea.  Screen shots don't look that fun, all numbers etc. Then has the reviews, which look good.

Print out three is almost identical except from some different terms (language specific) and different reviews.

Print outs four and five are nice and short, the opening paragraph finishes mid sentence before the more button, I like that shows there's more to read. But it does make you think if I read this I should read the rest. But then there isn't a lot to read. I like that. The first paragraph is all about the benefits, there's then a feature list. Actually that paragraph is different for US and GB. The screen shots look very good and only the US has reviews.

To summarise, blues description, he's made the screen shots prominent, he's got one sentence and the more link. I think this is a good idea, however I think he could have more than a sentence, it looks lacking. Looking at my other printouts, a paragraph looks better. I think he should have the benefits next.

I think having a features list looks good, I think you kind of expect it, a way to compare with other apps. I think that can consume a lot of the content you could waffle on about.

So what am I going to do, have an opening paragraph on benefits, have my more link,  then a feature / benefit list.  I guess I might talk a bit about the app next in a paragraph or two, taking care to mention the benefits.  Maybe I could add a video too, I'm not 100% sure on that. In the future I think after the benefits I should add some one line reviews.

by JM

Wednesday 21 April 2010

First impressions about iPhone development

The iPhone development language is called objective C and the development environment is called Xcode.

Obj-C, as its commonly abbreviated, is a C derivative language, with all the common syntax and operators available with C,and more, as you'd expect.  My background is mostly VB, but I've done some PHP in the last few years and have found this helpful in learning Obj-C, much of the syntax is the same.

Like other languages these days, there's help and example code to be found on the web. There are also forums where you can ask questions. However, you're expected to have a reasonable understanding of the language. I often find myself being referred to the documentation, which is only natural I guess.

I still need to learn about the framework and common functions.

I have found development of my first app quite slow, I tend to get stuck and unlike other languages I've used recently, am finding it hard to workaround my problems. However, I think this is due to a lack of familiarity with the language.

There still some fundamental concepts I need to learn but I hope I have got past the dip in the learning curve now.

by JM