diff --git a/ContaPessoas.xcodeproj/project.pbxproj b/ContaPessoas.xcodeproj/project.pbxproj index 9ce30d1..1dfb17a 100644 --- a/ContaPessoas.xcodeproj/project.pbxproj +++ b/ContaPessoas.xcodeproj/project.pbxproj @@ -15,10 +15,11 @@ 27A199B41A94B2A8008DC684 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 27A199B31A94B2A8008DC684 /* Images.xcassets */; }; 27A199B71A94B2A8008DC684 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 27A199B51A94B2A8008DC684 /* LaunchScreen.xib */; }; 27A199C31A94B2A8008DC684 /* ContaPessoasTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 27A199C21A94B2A8008DC684 /* ContaPessoasTests.m */; }; - 27A199CF1A94B4F3008DC684 /* girl.png in Resources */ = {isa = PBXBuildFile; fileRef = 27A199CE1A94B4F3008DC684 /* girl.png */; }; - 27A199D11A94B501008DC684 /* boy.png in Resources */ = {isa = PBXBuildFile; fileRef = 27A199D01A94B501008DC684 /* boy.png */; }; 27A199D31A94D1FA008DC684 /* Contador.m in Sources */ = {isa = PBXBuildFile; fileRef = 27A199D21A94D1FA008DC684 /* Contador.m */; }; 27A199D61A94D821008DC684 /* ContadorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 27A199D51A94D821008DC684 /* ContadorTests.m */; }; + E45383451A97578500E31131 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45383441A97578500E31131 /* AVFoundation.framework */; }; + E45383481A97593500E31131 /* Verde .mp3 in Resources */ = {isa = PBXBuildFile; fileRef = E45383461A97593500E31131 /* Verde .mp3 */; }; + E45383491A97593500E31131 /* Vermelho.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = E45383471A97593500E31131 /* Vermelho.mp3 */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -47,11 +48,13 @@ 27A199BC1A94B2A8008DC684 /* ContaPessoasTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ContaPessoasTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 27A199C11A94B2A8008DC684 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27A199C21A94B2A8008DC684 /* ContaPessoasTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ContaPessoasTests.m; sourceTree = ""; }; - 27A199CE1A94B4F3008DC684 /* girl.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = girl.png; sourceTree = ""; }; - 27A199D01A94B501008DC684 /* boy.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = boy.png; sourceTree = ""; }; 27A199D21A94D1FA008DC684 /* Contador.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Contador.m; sourceTree = ""; }; 27A199D41A94D22B008DC684 /* Contador.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Contador.h; sourceTree = ""; }; 27A199D51A94D821008DC684 /* ContadorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContadorTests.m; sourceTree = ""; }; + E45383431A974BD200E31131 /* Mostrador.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Mostrador.h; sourceTree = ""; }; + E45383441A97578500E31131 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; + E45383461A97593500E31131 /* Verde .mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = "Verde .mp3"; path = "../../JogoGenius/Genius/Verde .mp3"; sourceTree = ""; }; + E45383471A97593500E31131 /* Vermelho.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = Vermelho.mp3; path = ../../JogoGenius/Genius/Vermelho.mp3; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -59,6 +62,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + E45383451A97578500E31131 /* AVFoundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -75,6 +79,7 @@ 27A199971A94B2A8008DC684 = { isa = PBXGroup; children = ( + E45383441A97578500E31131 /* AVFoundation.framework */, 27A199A21A94B2A8008DC684 /* ContaPessoas */, 27A199BF1A94B2A8008DC684 /* ContaPessoasTests */, 27A199A11A94B2A8008DC684 /* Products */, @@ -93,8 +98,8 @@ 27A199A21A94B2A8008DC684 /* ContaPessoas */ = { isa = PBXGroup; children = ( - 27A199D01A94B501008DC684 /* boy.png */, - 27A199CE1A94B4F3008DC684 /* girl.png */, + E45383461A97593500E31131 /* Verde .mp3 */, + E45383471A97593500E31131 /* Vermelho.mp3 */, 27A199A71A94B2A8008DC684 /* AppDelegate.h */, 27A199A81A94B2A8008DC684 /* AppDelegate.m */, 27A199AA1A94B2A8008DC684 /* FirstViewController.h */, @@ -107,6 +112,7 @@ 27A199A31A94B2A8008DC684 /* Supporting Files */, 27A199D21A94D1FA008DC684 /* Contador.m */, 27A199D41A94D22B008DC684 /* Contador.h */, + E45383431A974BD200E31131 /* Mostrador.h */, ); path = ContaPessoas; sourceTree = ""; @@ -187,9 +193,11 @@ TargetAttributes = { 27A1999F1A94B2A8008DC684 = { CreatedOnToolsVersion = 6.1.1; + DevelopmentTeam = YBDF2UUEMG; }; 27A199BB1A94B2A8008DC684 = { CreatedOnToolsVersion = 6.1.1; + DevelopmentTeam = YBDF2UUEMG; TestTargetID = 27A1999F1A94B2A8008DC684; }; }; @@ -219,10 +227,10 @@ buildActionMask = 2147483647; files = ( 27A199B21A94B2A8008DC684 /* Main.storyboard in Resources */, - 27A199D11A94B501008DC684 /* boy.png in Resources */, - 27A199CF1A94B4F3008DC684 /* girl.png in Resources */, 27A199B71A94B2A8008DC684 /* LaunchScreen.xib in Resources */, + E45383481A97593500E31131 /* Verde .mp3 in Resources */, 27A199B41A94B2A8008DC684 /* Images.xcassets in Resources */, + E45383491A97593500E31131 /* Vermelho.mp3 in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -389,6 +397,8 @@ isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", @@ -400,6 +410,7 @@ INFOPLIST_FILE = ContaPessoasTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ContaPessoas.app/ContaPessoas"; }; name = Debug; @@ -408,6 +419,8 @@ isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", @@ -415,6 +428,7 @@ INFOPLIST_FILE = ContaPessoasTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ContaPessoas.app/ContaPessoas"; }; name = Release; @@ -438,6 +452,7 @@ 27A199C81A94B2A8008DC684 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 27A199C91A94B2A8008DC684 /* Build configuration list for PBXNativeTarget "ContaPessoasTests" */ = { isa = XCConfigurationList; @@ -446,6 +461,7 @@ 27A199CB1A94B2A8008DC684 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/ContaPessoas/Base.lproj/Main.storyboard b/ContaPessoas/Base.lproj/Main.storyboard index 99fa0dc..44666d8 100644 --- a/ContaPessoas/Base.lproj/Main.storyboard +++ b/ContaPessoas/Base.lproj/Main.storyboard @@ -4,7 +4,7 @@ - + @@ -13,63 +13,55 @@ - + - - - + - - - - - - - - - - - - + + - + - + @@ -78,82 +70,56 @@ - + - - - - - - - - - - - - - - - - - - - - + + @@ -185,9 +151,7 @@ - - diff --git a/ContaPessoas/Contador.h b/ContaPessoas/Contador.h index 18b7c16..26aa7d7 100644 --- a/ContaPessoas/Contador.h +++ b/ContaPessoas/Contador.h @@ -6,7 +6,13 @@ // Copyright (c) 2015 Vinicius Miana. All rights reserved. // -@interface Contador : NSObject +#import "Mostrador.h" + +@interface Contador : NSObject + +@property (nonatomic, assign) id update; + ++ (Contador *) instancia; - (void)maisUmCueca; - (void)maisUmaGata; @@ -14,5 +20,7 @@ -(int)getBoys; -(int)getGirls; +-(int)total; + @end diff --git a/ContaPessoas/Contador.m b/ContaPessoas/Contador.m index fa64ad8..4ba01ff 100644 --- a/ContaPessoas/Contador.m +++ b/ContaPessoas/Contador.m @@ -15,6 +15,18 @@ @implementation Contador { int girl; } +static Contador *_instancia = nil; + ++(Contador *) instancia { + if(_instancia == nil) + _instancia = [super allocWithZone:nil]; + return _instancia; +} + ++(id)allocWithZone:(struct _NSZone *)zone { + return [self instancia]; +} + -(id)init { self = [super init]; if (self) { @@ -25,10 +37,12 @@ -(id)init { } - (void)maisUmCueca { - boy = boy + 1; + boy++; + [_update atualiza]; } - (void)maisUmaGata { girl++; + [_update atualiza]; } -(int)getBoys { @@ -39,6 +53,10 @@ -(int)getGirls { return girl; } +-(int)total { + return boy + girl; +} + @end diff --git a/ContaPessoas/FirstViewController.h b/ContaPessoas/FirstViewController.h index 59c8301..14aecda 100644 --- a/ContaPessoas/FirstViewController.h +++ b/ContaPessoas/FirstViewController.h @@ -1,13 +1,13 @@ // // FirstViewController.h // ContaPessoas +// Esse programa é muito ruim // -// Created by Vinicius Miana on 2/18/15. +// Created by Isaías Lima on 02/19/15. // Copyright (c) 2015 Vinicius Miana. All rights reserved. // #import - @interface FirstViewController : UIViewController - (IBAction)clickBoy:(id)sender; diff --git a/ContaPessoas/FirstViewController.m b/ContaPessoas/FirstViewController.m index fc70dd5..cffa0cb 100644 --- a/ContaPessoas/FirstViewController.m +++ b/ContaPessoas/FirstViewController.m @@ -9,17 +9,11 @@ #import "FirstViewController.h" #import "Contador.h" -@interface FirstViewController () -@end - -@implementation FirstViewController { - Contador *contador; -} +@implementation FirstViewController - (void)viewDidLoad { [super viewDidLoad]; - contador = [[Contador alloc] init]; // Do any additional setup after loading the view, typically from a nib. } @@ -29,11 +23,13 @@ - (void)didReceiveMemoryWarning { } - (IBAction)clickBoy:(id)sender { + Contador *contador = [Contador instancia]; [contador maisUmCueca]; NSLog(@"Meninos - %i",[contador getBoys]); } - (IBAction)clickGirl:(id)sender { + Contador *contador = [Contador instancia]; [contador maisUmaGata]; NSLog(@"Meninas - %i",[contador getGirls]); } diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Contents.json b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Contents.json index 36d2c80..543eb10 100644 --- a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Contents.json @@ -1,63 +1,75 @@ { "images" : [ { - "idiom" : "iphone", "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-Small@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-Small@3x.png", "scale" : "3x" }, { - "idiom" : "iphone", "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-40@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-40@3x.png", "scale" : "3x" }, { - "idiom" : "iphone", "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-60@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-60@3x.png", "scale" : "3x" }, { - "idiom" : "ipad", "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-Small.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-Small@2x-1.png", "scale" : "2x" }, { - "idiom" : "ipad", "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-40.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-40@2x-1.png", "scale" : "2x" }, { - "idiom" : "ipad", "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-76.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-76@2x.png", "scale" : "2x" } ], diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-40.png b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-40.png new file mode 100644 index 0000000..cb2345c Binary files /dev/null and b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-40.png differ diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-40@2x-1.png b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-40@2x-1.png new file mode 100644 index 0000000..940bada Binary files /dev/null and b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-40@2x-1.png differ diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png new file mode 100644 index 0000000..940bada Binary files /dev/null and b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png differ diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-40@3x.png b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-40@3x.png new file mode 100644 index 0000000..61e446b Binary files /dev/null and b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-40@3x.png differ diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png new file mode 100644 index 0000000..61e446b Binary files /dev/null and b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png differ diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png new file mode 100644 index 0000000..21932e5 Binary files /dev/null and b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png differ diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-76.png b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-76.png new file mode 100644 index 0000000..3ae3fcb Binary files /dev/null and b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-76.png differ diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png new file mode 100644 index 0000000..5a64b5e Binary files /dev/null and b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png differ diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-Small.png b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-Small.png new file mode 100644 index 0000000..182d810 Binary files /dev/null and b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-Small.png differ diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png new file mode 100644 index 0000000..07a3341 Binary files /dev/null and b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png differ diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png new file mode 100644 index 0000000..07a3341 Binary files /dev/null and b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png differ diff --git a/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png new file mode 100644 index 0000000..8e40893 Binary files /dev/null and b/ContaPessoas/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png differ diff --git a/ContaPessoas/Info.plist b/ContaPessoas/Info.plist index 0c3a06e..7fc8751 100644 --- a/ContaPessoas/Info.plist +++ b/ContaPessoas/Info.plist @@ -23,7 +23,7 @@ LSRequiresIPhoneOS UILaunchStoryboardName - LaunchScreen + Main UIMainStoryboardFile Main UIRequiredDeviceCapabilities diff --git a/ContaPessoas/Mostrador.h b/ContaPessoas/Mostrador.h new file mode 100644 index 0000000..cfef631 --- /dev/null +++ b/ContaPessoas/Mostrador.h @@ -0,0 +1,13 @@ +// +// Mostrador.h +// ContaPessoas +// +// Created by Isaías Lima on 20/02/15. +// Copyright (c) 2015 Vinicius Miana. All rights reserved. +// + +@protocol Mostrador +@required +- (void)atualiza; + +@end diff --git a/ContaPessoas/SecondViewController.h b/ContaPessoas/SecondViewController.h index f907831..61ce846 100644 --- a/ContaPessoas/SecondViewController.h +++ b/ContaPessoas/SecondViewController.h @@ -7,13 +7,16 @@ // #import +#import "Mostrador.h" -@interface SecondViewController : UIViewController + +@interface SecondViewController : UIViewController { +} @property (weak, nonatomic) IBOutlet UILabel *totalBoys; @property (weak, nonatomic) IBOutlet UILabel *totalGirls; @property (weak, nonatomic) IBOutlet UILabel *total; -- (IBAction)click:(id)sender; + @end diff --git a/ContaPessoas/SecondViewController.m b/ContaPessoas/SecondViewController.m index a2a66f5..7eaadc0 100644 --- a/ContaPessoas/SecondViewController.m +++ b/ContaPessoas/SecondViewController.m @@ -9,30 +9,27 @@ #import "SecondViewController.h" #import "Contador.h" -@interface SecondViewController () { - Contador *contador; -} - -@end - @implementation SecondViewController + - (void)viewDidLoad { [super viewDidLoad]; - contador = [[Contador alloc] init]; + Contador *contador = [Contador instancia]; + contador.update = self; + [self atualiza]; } - - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -- (IBAction)click:(id)sender { +- (void)atualiza { + Contador *contador = [Contador instancia]; _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 total]]; } diff --git a/ContaPessoasTests/ContaPessoasTests.m b/ContaPessoasTests/ContaPessoasTests.m index 579bb3f..8a36f2f 100644 --- a/ContaPessoasTests/ContaPessoasTests.m +++ b/ContaPessoasTests/ContaPessoasTests.m @@ -21,6 +21,7 @@ - (void)testContaMeninos { Contador *c = [[Contador alloc] init]; [c maisUmCueca]; XCTAssert(([c getBoys] == 1), @"Pass"); + XCTAssert(([c getGirls] == 0), @"Pass"); } - (void)testContaMeninas {