Easy iPad Point Of Sale Application

Joined
May 31, 2014
Messages
2
Reaction score
0
Points
1
Hello everyone,

My name is Bart, from Belgium, and I'm a student who's started a business with my GF. We sell ice cream & coffee out of a vintage-renovated truck (Citroën HY).
For our business, we're looking for an iPad application, so we can keep track of our sales.

There are many Point of Sales applications available, but they are pricey and we only need the very basics.

I'm a student business engineering with Java experience, but Xcode is new for me. The app should consist of buttons for ice cream, irish coffee, espresso, ... that generates a subtotal the customer has to pay. When clicking on the paid-button, the subtotal should be cleared and the sales for ice cream, coffees, should be updated (in an other window that can be reached when clicking on a "view sales report"-button). Ideally, when clicking on the sale-buttons, a list on the right should appear with the current order (2 coffees, 3 Irish Coffees at a price of x euros for example).

For now, i'm trying to implement buttons and when clicked on, incrementing an integer value for the subtotal the client has to pay.

I'm looking at this: (with the help of Youtube)

viewcontroller.h file:
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController {
IBOutlet UILabel *subtotaalLbl;
int subtotaal;
}
- (IBAction)Eenbol;
- (IBAction)Tweebol;
- (IBAction)Driebol;
- (IBAction)Supplement;
- (IBAction)IrishCoffee;
- (IBAction)ItalianCoffee;
- (IBAction)FrenchCoffee;
- (IBAction)Koffie;
- (IBAction)Espresso;
- (IBAction)Deca;
- (IBAction)CafeGlace;
@end

viewcontroller.m file:
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
subtotaal = 0;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];

// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)Eenbol
{
subtotaal += 1.5;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];
}

- (IBAction)Tweebol
{
subtotaal += 2.5;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];
}

- (IBAction)Driebol
{
subtotaal += 3.5;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];
}

- (IBAction)Supplement
{
subtotaal += 0.5;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];
}

- (IBAction)Koffie
{
subtotaal += 2;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];
}

- (IBAction)Espresso
{
subtotaal += 2;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];
}

- (IBAction)Deca
{
subtotaal += 3.5;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];
}

- (IBAction)IrishCoffee
{
subtotaal += 5;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];
}

- (IBAction)ItalianCoffee
{
subtotaal += 5;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];
}

- (IBAction)FrenchCoffee
{
subtotaal += 5;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];
}

- (IBAction)CafeGlace
{
subtotaal += 3.5;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end


As I interpret this, I have declared buttons, an integer value and told the program to increment this integer value when clicked on these buttons. I created the buttons and label in the main storyboard file and linked them with the corresponding IBActions.

Still, I got this error:

2014-05-31 21:41:01.885 app kmk[745:60b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x8d9d210> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key label.'
***

What am I doing wrong? Also, a link to useful websites, extra information is always handy! Thank you in advance.

Bart Meylemans
 
Last edited:
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
The first thing that jumps out at me about your code, is that you are trying to assign a floating point number to an integer variable.

In your code you have this.\

int subtotaal;

Then this.

- (IBAction)Eenbol
{
subtotaal += 1.5;
[subtotaalLbl setText: [NSString stringWithFormat:mad:"%d", subtotaal]];
}

Tryt changing your subtotaal variable to a float like this, and then see what happens.
Also if your assing a whole number to it, then assign it like this.

Code:
float subtotaal;

- (IBAction)Eenbol
{
subtotaal += 1.0;
[subtotaalLbl setText: [NSString stringWithFormat:@"%.2f", subtotaal]];
}

You may also notice that I've changed the stringWithFormat: methods tokens, so that it displays a float number with two decimal places.

Regards Mark
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
Secondly you will have to access your subtotaalLbl like this.

Code:
[self subtotaalLbl setText: [NSString stringWithFormat:@"%.2f", subtotaal]];

Unless your going to synthesise the IBOutlet property of your label like this.

Code:
@implementation ViewController

@synthesize subtotaalLbl;

Then you can access the subtotaalLbl in your original way like this.

Code:
[subtotaalLbl setText: [NSString stringWithFormat:@"%.2f", subtotaal]];

The alternative if you don't want to synthesise the IBOutlet property, is to refer to the subtotaalLbl like this.

Code:
[_subtotaalLbl setText: [NSString stringWithFormat:@"%.2f", subtotaal]];

I think this is where the error message you posted is coming from.

Regards Mark
 
OP
B
Joined
May 31, 2014
Messages
2
Reaction score
0
Points
1
I have switched from integer to floating point notation. However, the error in the simulator came from a "double referenced button". I had accidently linked a button in the main storyboard to the IBOutlet UILabel, but after correcting my mistake, the link with the IBOutlet remained in the program. It took me a while to have that figured out, though.

Thanks Mark!


The first thing that jumps out at me about your code, is that you are trying to assign a floating point number to an integer variable.

In your code you have this.\



Then this.



Tryt changing your subtotaal variable to a float like this, and then see what happens.
Also if your assing a whole number to it, then assign it like this.

Code:
float subtotaal;

- (IBAction)Eenbol
{
subtotaal += 1.0;
[subtotaalLbl setText: [NSString stringWithFormat:@"%.2f", subtotaal]];
}

You may also notice that I've changed the stringWithFormat: methods tokens, so that it displays a float number with two decimal places.

Regards Mark

Secondly you will have to access your subtotaalLbl like this.

Code:
[self subtotaalLbl setText: [NSString stringWithFormat:@"%.2f", subtotaal]];

Unless your going to synthesise the IBOutlet property of your label like this.

Code:
@implementation ViewController

@synthesize subtotaalLbl;

Then you can access the subtotaalLbl in your original way like this.

Code:
[subtotaalLbl setText: [NSString stringWithFormat:@"%.2f", subtotaal]];

The alternative if you don't want to synthesise the IBOutlet property, is to refer to the subtotaalLbl like this.

Code:
[_subtotaalLbl setText: [NSString stringWithFormat:@"%.2f", subtotaal]];

I think this is where the error message you posted is coming from.

Regards Mark
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top