From ea4c938dc4c074b0fec2fc8a9d517590a7488bdd Mon Sep 17 00:00:00 2001 From: ezequieloliveiralima Date: Thu, 19 Feb 2015 14:24:30 -0200 Subject: [PATCH 1/2] teste --- ContaPessoas/Contador.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ContaPessoas/Contador.m b/ContaPessoas/Contador.m index fa64ad8..b6889a1 100644 --- a/ContaPessoas/Contador.m +++ b/ContaPessoas/Contador.m @@ -39,7 +39,7 @@ -(int)getGirls { return girl; } - +// Teste @end From 343157627a6876488fda88a817e8728e4f8f0975 Mon Sep 17 00:00:00 2001 From: ezequieloliveiralima Date: Thu, 19 Feb 2015 16:33:08 -0200 Subject: [PATCH 2/2] Tudo o que foi pedido para o dia 19/02 --- ContaPessoas/Contador.h | 11 ++++++---- ContaPessoas/Contador.m | 32 +++++++++++++++++++++++++++-- ContaPessoas/FirstViewController.m | 2 +- ContaPessoas/SecondViewController.h | 4 ++++ ContaPessoas/SecondViewController.m | 4 ++-- 5 files changed, 44 insertions(+), 9 deletions(-) diff --git a/ContaPessoas/Contador.h b/ContaPessoas/Contador.h index 18b7c16..799dbf3 100644 --- a/ContaPessoas/Contador.h +++ b/ContaPessoas/Contador.h @@ -4,15 +4,18 @@ // // Created by Vinicius Miana on 2/18/15. // Copyright (c) 2015 Vinicius Miana. All rights reserved. -// -@interface Contador : NSObject + +@interface Contador : NSObject ++(Contador *) instancia; - (void)maisUmCueca; - (void)maisUmaGata; -(int)getBoys; -(int)getGirls; +-(void) setGirls:(int) n; +-(void) setBoys:(int) n; +-(int) getTotal; -@end - +@end \ No newline at end of file diff --git a/ContaPessoas/Contador.m b/ContaPessoas/Contador.m index b6889a1..a94028e 100644 --- a/ContaPessoas/Contador.m +++ b/ContaPessoas/Contador.m @@ -10,11 +10,24 @@ #import "Contador.h" -@implementation Contador { +@implementation Contador + +{ int boy; int girl; } +static Contador *_instancia = nil; + ++(Contador *) instancia +{ + if (_instancia == nil) { + _instancia = [[Contador alloc] init]; + } + + return _instancia; +} + -(id)init { self = [super init]; if (self) { @@ -39,7 +52,22 @@ -(int)getGirls { return girl; } -// Teste +-(void) setBoys:(int) n +{ + boy = n; +} + +-(void) setGirls:(int) n +{ + girl = n; +} + +-(int) getTotal +{ + return boy + girl; +} + +// Teste de pull request @end diff --git a/ContaPessoas/FirstViewController.m b/ContaPessoas/FirstViewController.m index fc70dd5..128e95a 100644 --- a/ContaPessoas/FirstViewController.m +++ b/ContaPessoas/FirstViewController.m @@ -19,7 +19,7 @@ @implementation FirstViewController { - (void)viewDidLoad { [super viewDidLoad]; - contador = [[Contador alloc] init]; + contador = [Contador instancia]; // Do any additional setup after loading the view, typically from a nib. } diff --git a/ContaPessoas/SecondViewController.h b/ContaPessoas/SecondViewController.h index f907831..909e9e9 100644 --- a/ContaPessoas/SecondViewController.h +++ b/ContaPessoas/SecondViewController.h @@ -17,3 +17,7 @@ @end +// Singleton +// getTotal +// teste getTotal +// Delegate \ No newline at end of file diff --git a/ContaPessoas/SecondViewController.m b/ContaPessoas/SecondViewController.m index a2a66f5..5e3cc38 100644 --- a/ContaPessoas/SecondViewController.m +++ b/ContaPessoas/SecondViewController.m @@ -19,7 +19,7 @@ @implementation SecondViewController - (void)viewDidLoad { [super viewDidLoad]; - contador = [[Contador alloc] init]; + contador = [Contador instancia]; } @@ -32,7 +32,7 @@ - (void)didReceiveMemoryWarning { - (IBAction)click:(id)sender { _totalBoys.text = [NSString stringWithFormat: @"%d", [contador getBoys]]; _totalGirls.text = [NSString stringWithFormat: @"%d", [contador getGirls]]; - _total.text = [NSString stringWithFormat:@"%d", [contador getGirls] + [contador getBoys] ]; + _total.text = [NSString stringWithFormat:@"%d", [contador getTotal] ]; }