Browse files

FIRST

  • Loading branch information...
0 parents commit 6f28affa08a240d3b1f4bc9af20d80eceb9e2e03 @enriquez committed Feb 13, 2013
8 .gitignore
@@ -0,0 +1,8 @@
+*.mode1
+*.mode1v3
+*.mode2v3
+*.perspective
+*.perspectivev3
+*.pbxuser
+*.xcodeproj/project.xcworkspace/
+*.xcodeproj/xcuserdata/
392 CheckMateShopper.xcodeproj/project.pbxproj
@@ -0,0 +1,392 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 051CD39816CC114900D9022C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051CD39716CC114900D9022C /* UIKit.framework */; };
+ 051CD39A16CC114900D9022C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051CD39916CC114900D9022C /* Foundation.framework */; };
+ 051CD39C16CC114900D9022C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051CD39B16CC114900D9022C /* CoreGraphics.framework */; };
+ 051CD39E16CC114900D9022C /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051CD39D16CC114900D9022C /* CoreData.framework */; };
+ 051CD3A416CC114900D9022C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 051CD3A216CC114900D9022C /* InfoPlist.strings */; };
+ 051CD3A616CC114900D9022C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 051CD3A516CC114900D9022C /* main.m */; };
+ 051CD3AA16CC114A00D9022C /* CMAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 051CD3A916CC114A00D9022C /* CMAppDelegate.m */; };
+ 051CD3AC16CC114A00D9022C /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 051CD3AB16CC114A00D9022C /* Default.png */; };
+ 051CD3AE16CC114A00D9022C /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 051CD3AD16CC114A00D9022C /* Default@2x.png */; };
+ 051CD3B016CC114A00D9022C /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 051CD3AF16CC114A00D9022C /* Default-568h@2x.png */; };
+ 051CD3B316CC114A00D9022C /* CheckMateShopper.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 051CD3B116CC114A00D9022C /* CheckMateShopper.xcdatamodeld */; };
+ 051CD3C316CC135200D9022C /* CMShopperHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 051CD3C216CC135200D9022C /* CMShopperHTTPClient.m */; };
+ 051CD3C816CC13F600D9022C /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 051CD3C716CC13F600D9022C /* Storyboard.storyboard */; };
+ 051CD3D416CC214800D9022C /* CMNewItemViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 051CD3D316CC214800D9022C /* CMNewItemViewController.m */; };
+ 05FD91B216CC295C007646DE /* CMItemListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 05FD91B116CC295C007646DE /* CMItemListViewController.m */; };
+ 05FD91B816CC33A1007646DE /* CMItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 05FD91B716CC33A1007646DE /* CMItem.m */; };
+ 05FD91C416CC38CF007646DE /* CMCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 05FD91C316CC38CF007646DE /* CMCategory.m */; };
+ 05FD91C716CC4BE9007646DE /* CMEditItemViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 05FD91C616CC4BE9007646DE /* CMEditItemViewController.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 051CD39416CC114900D9022C /* CheckMateShopper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CheckMateShopper.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 051CD39716CC114900D9022C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ 051CD39916CC114900D9022C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 051CD39B16CC114900D9022C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ 051CD39D16CC114900D9022C /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
+ 051CD3A116CC114900D9022C /* CheckMateShopper-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CheckMateShopper-Info.plist"; sourceTree = "<group>"; };
+ 051CD3A316CC114900D9022C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ 051CD3A516CC114900D9022C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 051CD3A716CC114900D9022C /* CheckMateShopper-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CheckMateShopper-Prefix.pch"; sourceTree = "<group>"; };
+ 051CD3A816CC114900D9022C /* CMAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CMAppDelegate.h; sourceTree = "<group>"; };
+ 051CD3A916CC114A00D9022C /* CMAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CMAppDelegate.m; sourceTree = "<group>"; };
+ 051CD3AB16CC114A00D9022C /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
+ 051CD3AD16CC114A00D9022C /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = "<group>"; };
+ 051CD3AF16CC114A00D9022C /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
+ 051CD3B216CC114A00D9022C /* CheckMateShopper.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = CheckMateShopper.xcdatamodel; sourceTree = "<group>"; };
+ 051CD3C116CC135200D9022C /* CMShopperHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CMShopperHTTPClient.h; path = Vendor/CMShopperHTTPClient/CMShopperHTTPClient.h; sourceTree = "<group>"; };
+ 051CD3C216CC135200D9022C /* CMShopperHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CMShopperHTTPClient.m; path = Vendor/CMShopperHTTPClient/CMShopperHTTPClient.m; sourceTree = "<group>"; };
+ 051CD3C716CC13F600D9022C /* Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Storyboard.storyboard; sourceTree = "<group>"; };
+ 051CD3D216CC214800D9022C /* CMNewItemViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CMNewItemViewController.h; path = Controllers/CMNewItemViewController.h; sourceTree = "<group>"; };
+ 051CD3D316CC214800D9022C /* CMNewItemViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CMNewItemViewController.m; path = Controllers/CMNewItemViewController.m; sourceTree = "<group>"; };
+ 05FD91B016CC295C007646DE /* CMItemListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CMItemListViewController.h; path = Controllers/CMItemListViewController.h; sourceTree = "<group>"; };
+ 05FD91B116CC295C007646DE /* CMItemListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CMItemListViewController.m; path = Controllers/CMItemListViewController.m; sourceTree = "<group>"; };
+ 05FD91B616CC33A1007646DE /* CMItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CMItem.h; path = Models/CMItem.h; sourceTree = "<group>"; };
+ 05FD91B716CC33A1007646DE /* CMItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CMItem.m; path = Models/CMItem.m; sourceTree = "<group>"; };
+ 05FD91C216CC38CF007646DE /* CMCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CMCategory.h; path = Models/CMCategory.h; sourceTree = "<group>"; };
+ 05FD91C316CC38CF007646DE /* CMCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CMCategory.m; path = Models/CMCategory.m; sourceTree = "<group>"; };
+ 05FD91C516CC4BE9007646DE /* CMEditItemViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CMEditItemViewController.h; path = Controllers/CMEditItemViewController.h; sourceTree = "<group>"; };
+ 05FD91C616CC4BE9007646DE /* CMEditItemViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CMEditItemViewController.m; path = Controllers/CMEditItemViewController.m; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 051CD39116CC114900D9022C /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 051CD39816CC114900D9022C /* UIKit.framework in Frameworks */,
+ 051CD39A16CC114900D9022C /* Foundation.framework in Frameworks */,
+ 051CD39C16CC114900D9022C /* CoreGraphics.framework in Frameworks */,
+ 051CD39E16CC114900D9022C /* CoreData.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 051CD38B16CC114900D9022C = {
+ isa = PBXGroup;
+ children = (
+ 051CD39F16CC114900D9022C /* CheckMateShopper */,
+ 051CD39616CC114900D9022C /* Frameworks */,
+ 051CD39516CC114900D9022C /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ 051CD39516CC114900D9022C /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 051CD39416CC114900D9022C /* CheckMateShopper.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 051CD39616CC114900D9022C /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 051CD39716CC114900D9022C /* UIKit.framework */,
+ 051CD39916CC114900D9022C /* Foundation.framework */,
+ 051CD39B16CC114900D9022C /* CoreGraphics.framework */,
+ 051CD39D16CC114900D9022C /* CoreData.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 051CD39F16CC114900D9022C /* CheckMateShopper */ = {
+ isa = PBXGroup;
+ children = (
+ 051CD3B116CC114A00D9022C /* CheckMateShopper.xcdatamodeld */,
+ 051CD3A816CC114900D9022C /* CMAppDelegate.h */,
+ 051CD3A916CC114A00D9022C /* CMAppDelegate.m */,
+ 051CD3BB16CC11E700D9022C /* Controllers */,
+ 051CD3B916CC11DA00D9022C /* Models */,
+ 051CD3C716CC13F600D9022C /* Storyboard.storyboard */,
+ 051CD3A016CC114900D9022C /* Supporting Files */,
+ 051CD3BF16CC133000D9022C /* Vendor */,
+ 051CD3BA16CC11DE00D9022C /* Views */,
+ );
+ path = CheckMateShopper;
+ sourceTree = "<group>";
+ };
+ 051CD3A016CC114900D9022C /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 051CD3A116CC114900D9022C /* CheckMateShopper-Info.plist */,
+ 051CD3A216CC114900D9022C /* InfoPlist.strings */,
+ 051CD3A516CC114900D9022C /* main.m */,
+ 051CD3A716CC114900D9022C /* CheckMateShopper-Prefix.pch */,
+ 051CD3AB16CC114A00D9022C /* Default.png */,
+ 051CD3AD16CC114A00D9022C /* Default@2x.png */,
+ 051CD3AF16CC114A00D9022C /* Default-568h@2x.png */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ 051CD3B916CC11DA00D9022C /* Models */ = {
+ isa = PBXGroup;
+ children = (
+ 05FD91C216CC38CF007646DE /* CMCategory.h */,
+ 05FD91C316CC38CF007646DE /* CMCategory.m */,
+ 05FD91B616CC33A1007646DE /* CMItem.h */,
+ 05FD91B716CC33A1007646DE /* CMItem.m */,
+ );
+ name = Models;
+ sourceTree = "<group>";
+ };
+ 051CD3BA16CC11DE00D9022C /* Views */ = {
+ isa = PBXGroup;
+ children = (
+ );
+ name = Views;
+ sourceTree = "<group>";
+ };
+ 051CD3BB16CC11E700D9022C /* Controllers */ = {
+ isa = PBXGroup;
+ children = (
+ 05FD91C516CC4BE9007646DE /* CMEditItemViewController.h */,
+ 05FD91C616CC4BE9007646DE /* CMEditItemViewController.m */,
+ 05FD91B016CC295C007646DE /* CMItemListViewController.h */,
+ 05FD91B116CC295C007646DE /* CMItemListViewController.m */,
+ 051CD3D216CC214800D9022C /* CMNewItemViewController.h */,
+ 051CD3D316CC214800D9022C /* CMNewItemViewController.m */,
+ );
+ name = Controllers;
+ sourceTree = "<group>";
+ };
+ 051CD3BF16CC133000D9022C /* Vendor */ = {
+ isa = PBXGroup;
+ children = (
+ 051CD3C016CC133500D9022C /* CMShopperHTTPClient */,
+ );
+ name = Vendor;
+ sourceTree = "<group>";
+ };
+ 051CD3C016CC133500D9022C /* CMShopperHTTPClient */ = {
+ isa = PBXGroup;
+ children = (
+ 051CD3C116CC135200D9022C /* CMShopperHTTPClient.h */,
+ 051CD3C216CC135200D9022C /* CMShopperHTTPClient.m */,
+ );
+ name = CMShopperHTTPClient;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 051CD39316CC114900D9022C /* CheckMateShopper */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 051CD3B616CC114A00D9022C /* Build configuration list for PBXNativeTarget "CheckMateShopper" */;
+ buildPhases = (
+ 051CD39016CC114900D9022C /* Sources */,
+ 051CD39116CC114900D9022C /* Frameworks */,
+ 051CD39216CC114900D9022C /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = CheckMateShopper;
+ productName = CheckMateShopper;
+ productReference = 051CD39416CC114900D9022C /* CheckMateShopper.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 051CD38C16CC114900D9022C /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ CLASSPREFIX = CM;
+ LastUpgradeCheck = 0460;
+ ORGANIZATIONNAME = "Mike Enriquez";
+ };
+ buildConfigurationList = 051CD38F16CC114900D9022C /* Build configuration list for PBXProject "CheckMateShopper" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 051CD38B16CC114900D9022C;
+ productRefGroup = 051CD39516CC114900D9022C /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 051CD39316CC114900D9022C /* CheckMateShopper */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 051CD39216CC114900D9022C /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 051CD3A416CC114900D9022C /* InfoPlist.strings in Resources */,
+ 051CD3AC16CC114A00D9022C /* Default.png in Resources */,
+ 051CD3AE16CC114A00D9022C /* Default@2x.png in Resources */,
+ 051CD3B016CC114A00D9022C /* Default-568h@2x.png in Resources */,
+ 051CD3C816CC13F600D9022C /* Storyboard.storyboard in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 051CD39016CC114900D9022C /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 051CD3A616CC114900D9022C /* main.m in Sources */,
+ 051CD3AA16CC114A00D9022C /* CMAppDelegate.m in Sources */,
+ 051CD3B316CC114A00D9022C /* CheckMateShopper.xcdatamodeld in Sources */,
+ 051CD3C316CC135200D9022C /* CMShopperHTTPClient.m in Sources */,
+ 051CD3D416CC214800D9022C /* CMNewItemViewController.m in Sources */,
+ 05FD91B216CC295C007646DE /* CMItemListViewController.m in Sources */,
+ 05FD91B816CC33A1007646DE /* CMItem.m in Sources */,
+ 05FD91C416CC38CF007646DE /* CMCategory.m in Sources */,
+ 05FD91C716CC4BE9007646DE /* CMEditItemViewController.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 051CD3A216CC114900D9022C /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 051CD3A316CC114900D9022C /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 051CD3B416CC114A00D9022C /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 6.1;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 051CD3B516CC114A00D9022C /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 6.1;
+ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 051CD3B716CC114A00D9022C /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "CheckMateShopper/CheckMateShopper-Prefix.pch";
+ INFOPLIST_FILE = "CheckMateShopper/CheckMateShopper-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ 051CD3B816CC114A00D9022C /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "CheckMateShopper/CheckMateShopper-Prefix.pch";
+ INFOPLIST_FILE = "CheckMateShopper/CheckMateShopper-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 051CD38F16CC114900D9022C /* Build configuration list for PBXProject "CheckMateShopper" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 051CD3B416CC114A00D9022C /* Debug */,
+ 051CD3B516CC114A00D9022C /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 051CD3B616CC114A00D9022C /* Build configuration list for PBXNativeTarget "CheckMateShopper" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 051CD3B716CC114A00D9022C /* Debug */,
+ 051CD3B816CC114A00D9022C /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+
+/* Begin XCVersionGroup section */
+ 051CD3B116CC114A00D9022C /* CheckMateShopper.xcdatamodeld */ = {
+ isa = XCVersionGroup;
+ children = (
+ 051CD3B216CC114A00D9022C /* CheckMateShopper.xcdatamodel */,
+ );
+ currentVersion = 051CD3B216CC114A00D9022C /* CheckMateShopper.xcdatamodel */;
+ path = CheckMateShopper.xcdatamodeld;
+ sourceTree = "<group>";
+ versionGroupType = wrapper.xcdatamodel;
+ };
+/* End XCVersionGroup section */
+ };
+ rootObject = 051CD38C16CC114900D9022C /* Project object */;
+}
22 CheckMateShopper/CMAppDelegate.h
@@ -0,0 +1,22 @@
+//
+// CMAppDelegate.h
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface CMAppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
+@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
+@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
+
+- (void)saveContext;
+- (NSURL *)applicationDocumentsDirectory;
+
+@end
145 CheckMateShopper/CMAppDelegate.m
@@ -0,0 +1,145 @@
+//
+// CMAppDelegate.m
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import "CMAppDelegate.h"
+
+@implementation CMAppDelegate
+
+@synthesize managedObjectContext = _managedObjectContext;
+@synthesize managedObjectModel = _managedObjectModel;
+@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application
+{
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application
+{
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application
+{
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ // Saves changes in the application's managed object context before the application terminates.
+ [self saveContext];
+}
+
+- (void)saveContext
+{
+ NSError *error = nil;
+ NSManagedObjectContext *managedObjectContext = self.managedObjectContext;
+ if (managedObjectContext != nil) {
+ if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
+ // Replace this implementation with code to handle the error appropriately.
+ // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
+ NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
+ abort();
+ }
+ }
+}
+
+#pragma mark - Core Data stack
+
+// Returns the managed object context for the application.
+// If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
+- (NSManagedObjectContext *)managedObjectContext
+{
+ if (_managedObjectContext != nil) {
+ return _managedObjectContext;
+ }
+
+ NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
+ if (coordinator != nil) {
+ _managedObjectContext = [[NSManagedObjectContext alloc] init];
+ [_managedObjectContext setPersistentStoreCoordinator:coordinator];
+ }
+ return _managedObjectContext;
+}
+
+// Returns the managed object model for the application.
+// If the model doesn't already exist, it is created from the application's model.
+- (NSManagedObjectModel *)managedObjectModel
+{
+ if (_managedObjectModel != nil) {
+ return _managedObjectModel;
+ }
+ NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"CheckMateShopper" withExtension:@"momd"];
+ _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
+ return _managedObjectModel;
+}
+
+// Returns the persistent store coordinator for the application.
+// If the coordinator doesn't already exist, it is created and the application's store added to it.
+- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
+{
+ if (_persistentStoreCoordinator != nil) {
+ return _persistentStoreCoordinator;
+ }
+
+ NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"CheckMateShopper.sqlite"];
+
+ NSError *error = nil;
+ _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
+ if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
+ /*
+ Replace this implementation with code to handle the error appropriately.
+
+ abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
+
+ Typical reasons for an error here include:
+ * The persistent store is not accessible;
+ * The schema for the persistent store is incompatible with current managed object model.
+ Check the error message to determine what the actual problem was.
+
+
+ If the persistent store is not accessible, there is typically something wrong with the file path. Often, a file URL is pointing into the application's resources directory instead of a writeable directory.
+
+ If you encounter schema incompatibility errors during development, you can reduce their frequency by:
+ * Simply deleting the existing store:
+ [[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil]
+
+ * Performing automatic lightweight migration by passing the following dictionary as the options parameter:
+ @{NSMigratePersistentStoresAutomaticallyOption:@YES, NSInferMappingModelAutomaticallyOption:@YES}
+
+ Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details.
+
+ */
+ NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
+ abort();
+ }
+
+ return _persistentStoreCoordinator;
+}
+
+#pragma mark - Application's Documents directory
+
+// Returns the URL to the application's Documents directory.
+- (NSURL *)applicationDocumentsDirectory
+{
+ return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
+}
+
+@end
47 CheckMateShopper/CheckMateShopper-Info.plist
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.mikeenriquez.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UIMainStoryboardFile</key>
+ <string>Storyboard</string>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+ <key>UISupportedInterfaceOrientations~ipad</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
19 CheckMateShopper/CheckMateShopper-Prefix.pch
@@ -0,0 +1,19 @@
+//
+// Prefix header for all source files of the 'CheckMateShopper' target in the 'CheckMateShopper' project
+//
+
+#import <Availability.h>
+
+#ifndef __IPHONE_3_0
+#warning "This project uses features only available in iOS SDK 3.0 and later."
+#endif
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+ #import <Foundation/Foundation.h>
+ #import <CoreData/CoreData.h>
+#endif
+
+#import "CMCategory.h"
+#import "CMItem.h"
+#import "CMShopperHTTPClient.h"
8 CheckMateShopper/CheckMateShopper.xcdatamodeld/.xccurrentversion
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>_XCCurrentVersionName</key>
+ <string>CheckMateShopper.xcdatamodel</string>
+</dict>
+</plist>
16 CheckMateShopper/CheckMateShopper.xcdatamodeld/CheckMateShopper.xcdatamodel/contents
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<model name="" userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="2057" systemVersion="12C60" minimumToolsVersion="Automatic" macOSVersion="Automatic" iOSVersion="Automatic">
+ <entity name="CMCategory" representedClassName="CMCategory" syncable="YES">
+ <attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
+ <relationship name="items" optional="YES" toMany="YES" deletionRule="Nullify" ordered="YES" destinationEntity="CMItem" inverseName="category" inverseEntity="CMItem" syncable="YES"/>
+ </entity>
+ <entity name="CMItem" representedClassName="CMItem" syncable="YES">
+ <attribute name="itemId" optional="YES" attributeType="String" syncable="YES"/>
+ <attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
+ <relationship name="category" optional="YES" minCount="1" maxCount="1" deletionRule="Nullify" destinationEntity="CMCategory" inverseName="items" inverseEntity="CMCategory" syncable="YES"/>
+ </entity>
+ <elements>
+ <element name="CMItem" positionX="160" positionY="192" width="128" height="90"/>
+ <element name="CMCategory" positionX="160" positionY="192" width="128" height="75"/>
+ </elements>
+</model>
19 CheckMateShopper/Controllers/CMEditItemViewController.h
@@ -0,0 +1,19 @@
+//
+// CMEditItemViewController.h
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface CMEditItemViewController : UIViewController
+- (IBAction)save:(id)sender;
+- (IBAction)cancel:(id)sender;
+- (IBAction)deleteItem:(id)sender;
+@property (weak, nonatomic) IBOutlet UITextField *nameTextField;
+@property (weak, nonatomic) IBOutlet UITextField *categoryTextField;
+@property (strong, nonatomic) NSManagedObjectContext *context;
+@property (strong, nonatomic) CMItem *item;
+@end
69 CheckMateShopper/Controllers/CMEditItemViewController.m
@@ -0,0 +1,69 @@
+//
+// CMEditItemViewController.m
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import "CMEditItemViewController.h"
+
+@interface CMEditItemViewController ()
+
+@end
+
+@implementation CMEditItemViewController
+
+#pragma mark UIVIewController
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+ self.nameTextField.text = self.item.name;
+ self.categoryTextField.text = ((CMCategory *)self.item.category).name;
+}
+
+- (void)didReceiveMemoryWarning
+{
+ [super didReceiveMemoryWarning];
+ _context = nil;
+ _item = nil;
+}
+
+#pragma mark IBActions
+
+- (IBAction)save:(id)sender {
+ NSString *itemName = self.nameTextField.text;
+ NSString *categoryName = self.categoryTextField.text;
+
+ if (itemName.length > 0 && categoryName.length > 0) {
+ CMShopperHTTPClient *httpClient = [CMShopperHTTPClient sharedInstance];
+ [httpClient updateItemWithId:self.item.itemId name:itemName category:categoryName onComplete:^(NSDictionary *item, NSError *error) {
+ if (error) {
+ NSLog(@"TODO: alert");
+ } else {
+ [self.context deleteObject:self.item];
+ [self dismissViewControllerAnimated:YES completion:nil];
+ }
+ }];
+ } else {
+ NSLog(@"TODO: alert");
+ }
+}
+
+- (IBAction)cancel:(id)sender {
+ [self dismissViewControllerAnimated:YES completion:nil];
+}
+
+- (IBAction)deleteItem:(id)sender {
+ CMShopperHTTPClient *httpClient = [CMShopperHTTPClient sharedInstance];
+ [httpClient deleteItemWithId:self.item.itemId onComplete:^(NSError *error) {
+ if (error) {
+ NSLog(@"TODO: alert");
+ } else {
+ [self.context deleteObject:self.item];
+ [self dismissViewControllerAnimated:YES completion:nil];
+ }
+ }];
+}
+@end
14 CheckMateShopper/Controllers/CMItemListViewController.h
@@ -0,0 +1,14 @@
+//
+// CMItemListViewController.h
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface CMItemListViewController : UITableViewController <NSFetchedResultsControllerDelegate, UITableViewDataSource, UITableViewDelegate>
+@property (strong, nonatomic) IBOutlet UITableView *table;
+@property (strong, nonatomic) NSManagedObjectContext *context;
+@end
208 CheckMateShopper/Controllers/CMItemListViewController.m
@@ -0,0 +1,208 @@
+//
+// CMItemListViewController.m
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import "CMItemListViewController.h"
+#import "CMNewItemViewController.h"
+#import "CMEditItemViewController.h"
+#import "CMAppDelegate.h"
+
+@interface CMItemListViewController ()
+@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
+- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
+- (void)synchronizeWithServerOnComplete:(void(^)(NSError *error))completeBlock;
+@end
+
+@implementation CMItemListViewController
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+
+ UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
+ [refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
+ [self.table addSubview:refreshControl];
+
+ self.context = ((CMAppDelegate *)[UIApplication sharedApplication].delegate).managedObjectContext;
+ [self.fetchedResultsController performFetch:nil];
+}
+
+- (void)viewWillAppear:(BOOL)animated
+{
+ [super viewWillAppear:animated];
+ [self synchronizeWithServerOnComplete:nil];
+}
+
+- (void)didReceiveMemoryWarning
+{
+ [super didReceiveMemoryWarning];
+
+ _table = nil;
+ _context = nil;
+ _fetchedResultsController = nil;
+}
+
+#pragma mark - Properties
+
+- (NSFetchedResultsController *)fetchedResultsController {
+ if (_fetchedResultsController) return _fetchedResultsController;
+
+ NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
+ fetchRequest.entity = [NSEntityDescription entityForName:@"CMItem" inManagedObjectContext:self.context];
+ fetchRequest.fetchBatchSize = 30;
+ fetchRequest.sortDescriptors = [NSArray arrayWithObjects:[NSSortDescriptor sortDescriptorWithKey:@"category.name" ascending:YES], [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES], nil];
+
+ _fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
+ managedObjectContext:self.context
+ sectionNameKeyPath:@"category.name"
+ cacheName:nil];
+ _fetchedResultsController.delegate = self;
+
+ return _fetchedResultsController;
+}
+
+#pragma mark - Table view data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ NSArray *sections = [self.fetchedResultsController sections];
+ return sections.count;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ NSArray *sections = [self.fetchedResultsController sections];
+ id <NSFetchedResultsSectionInfo> sectionInfo = [sections objectAtIndex:section];
+ return sectionInfo.numberOfObjects;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ static NSString *CellIdentifier = @"ItemCell";
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
+
+ [self configureCell:cell atIndexPath:indexPath];
+
+ return cell;
+}
+
+- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
+{
+ NSArray *sections = [self.fetchedResultsController sections];
+ id <NSFetchedResultsSectionInfo> sectionInfo = [sections objectAtIndex:section];
+ return sectionInfo.name;
+}
+
+#pragma mark - NSFetchedResultsControllerDelegate
+
+- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
+{
+ [self.table beginUpdates];
+}
+
+- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath
+{
+
+ UITableView *tableView = self.table;
+
+ switch(type) {
+
+ case NSFetchedResultsChangeInsert:
+ [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationNone];
+ break;
+
+ case NSFetchedResultsChangeDelete:
+ [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
+ break;
+
+ case NSFetchedResultsChangeUpdate:
+ [self configureCell:(UITableViewCell *)[self.table cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
+ break;
+ }
+}
+
+- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id )sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
+{
+ switch(type) {
+
+ case NSFetchedResultsChangeInsert:
+ [self.table insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationNone];
+ break;
+
+ case NSFetchedResultsChangeDelete:
+ [self.table deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationNone];
+ break;
+ }
+}
+
+- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
+{
+ [self.table endUpdates];
+ [self.table reloadData];
+}
+
+#pragma mark - UIViewController
+
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
+{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
+ [self performSelector:NSSelectorFromString(segue.identifier) withObject:segue.destinationViewController];
+#pragma clang diagnostic pop
+}
+
+#pragma mark - Prepare for segue methods
+
+- (void)prepareNewItemViewController:(CMNewItemViewController *)newItemViewController
+{
+ newItemViewController.context = self.context;
+}
+
+- (void)prepareEditItemViewController:(CMEditItemViewController *)editItemViewController
+{
+ CMItem *item = (CMItem *)[self.fetchedResultsController objectAtIndexPath:[self.table indexPathForSelectedRow]];
+ editItemViewController.item = item;
+ editItemViewController.context = self.context;
+}
+
+#pragma mark - Private
+
+- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
+{
+ CMItem *item = (CMItem *)[self.fetchedResultsController objectAtIndexPath:indexPath];
+ cell.textLabel.text = item.name;
+}
+
+- (void)synchronizeWithServerOnComplete:(void(^)(NSError *error))completeBlock;
+{
+ CMShopperHTTPClient *httpClient = [CMShopperHTTPClient sharedInstance];
+ [httpClient listItemsOnComplete:^(NSArray *items, NSError *error) {
+ if (error) {
+ NSLog(@"TODO: alert");
+ } else {
+ for (NSDictionary *itemJson in items) {
+ NSString *itemId = [itemJson objectForKey:@"id"];
+ CMItem *item = [CMItem findOrBuildById:itemId inContext:self.context];
+ [item unpackDictionary:itemJson inContext:self.context];
+ }
+
+ [self.context save:nil];
+ [self.fetchedResultsController performFetch:nil];
+ }
+
+ if (completeBlock) completeBlock(error);
+ }];
+}
+
+- (void)handleRefresh:(UIRefreshControl *)refreshControl
+{
+ [self synchronizeWithServerOnComplete:^(NSError *error) {
+ [refreshControl endRefreshing];
+ }];
+}
+
+@end
17 CheckMateShopper/Controllers/CMNewItemViewController.h
@@ -0,0 +1,17 @@
+//
+// CMNewItemViewController.h
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface CMNewItemViewController : UIViewController
+@property (strong, nonatomic) NSManagedObjectContext *context;
+@property (weak, nonatomic) IBOutlet UITextField *nameTextField;
+@property (weak, nonatomic) IBOutlet UITextField *categoryTextField;
+- (IBAction)save:(id)sender;
+- (IBAction)cancel:(id)sender;
+@end
48 CheckMateShopper/Controllers/CMNewItemViewController.m
@@ -0,0 +1,48 @@
+//
+// CMNewItemViewController.m
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import "CMNewItemViewController.h"
+
+@interface CMNewItemViewController ()
+
+@end
+
+@implementation CMNewItemViewController
+
+#pragma mark UIVIewController
+
+- (void)didReceiveMemoryWarning
+{
+ [super didReceiveMemoryWarning];
+ _context = nil;
+}
+
+#pragma mark IBActions
+
+- (IBAction)save:(id)sender {
+ NSString *itemName = self.nameTextField.text;
+ NSString *categoryName = self.categoryTextField.text;
+
+ if (itemName.length > 0 && categoryName.length > 0) {
+ CMShopperHTTPClient *httpClient = [CMShopperHTTPClient sharedInstance];
+ [httpClient createItemWithName:itemName category:categoryName onComplete:^(NSDictionary *item, NSError *error) {
+ if (error) {
+ NSLog(@"TODO: alert");
+ } else {
+ [self dismissViewControllerAnimated:YES completion:nil];
+ }
+ }];
+ } else {
+ NSLog(@"TODO: alert");
+ }
+}
+
+- (IBAction)cancel:(id)sender {
+ [self dismissViewControllerAnimated:YES completion:nil];
+}
+@end
BIN CheckMateShopper/Default-568h@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN CheckMateShopper/Default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN CheckMateShopper/Default@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 CheckMateShopper/Models/CMCategory.h
@@ -0,0 +1,35 @@
+//
+// CMCategory.h
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <CoreData/CoreData.h>
+
+@class CMItem;
+
+@interface CMCategory : NSManagedObject <NSFetchedResultsSectionInfo>
+
+@property (nonatomic, retain) NSString * name;
+@property (nonatomic, retain) NSOrderedSet *items;
+@end
+
+@interface CMCategory (CoreDataGeneratedAccessors)
+
++ (CMCategory *)findOrBuildByName:(NSString *)name inContext:(NSManagedObjectContext *)context;
+- (id)initWithContext:(NSManagedObjectContext *)context;
+
+- (void)insertObject:(CMItem *)value inItemsAtIndex:(NSUInteger)idx;
+- (void)removeObjectFromItemsAtIndex:(NSUInteger)idx;
+- (void)insertItems:(NSArray *)value atIndexes:(NSIndexSet *)indexes;
+- (void)removeItemsAtIndexes:(NSIndexSet *)indexes;
+- (void)replaceObjectInItemsAtIndex:(NSUInteger)idx withObject:(CMItem *)value;
+- (void)replaceItemsAtIndexes:(NSIndexSet *)indexes withItems:(NSArray *)values;
+- (void)addItemsObject:(CMItem *)value;
+- (void)removeItemsObject:(CMItem *)value;
+- (void)addItems:(NSOrderedSet *)values;
+- (void)removeItems:(NSOrderedSet *)values;
+@end
62 CheckMateShopper/Models/CMCategory.m
@@ -0,0 +1,62 @@
+//
+// CMCategory.m
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import "CMCategory.h"
+#import "CMItem.h"
+
+
+@implementation CMCategory
+
+@dynamic name;
+@dynamic items;
+
++ (CMCategory *)findOrBuildByName:(NSString *)name inContext:(NSManagedObjectContext *)context
+{
+ NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"CMCategory"];
+ fetchRequest.fetchLimit = 1;
+ fetchRequest.predicate = [NSPredicate predicateWithFormat:@"name = %@", name];
+
+ NSArray *results = [context executeFetchRequest:fetchRequest error:nil];
+
+ if (results.count > 0) {
+ return [results objectAtIndex:0];
+ } else {
+ CMCategory *category = [[CMCategory alloc] initWithContext:context];
+ category.name = name;
+ return category;
+ }
+}
+
+- (id)initWithContext:(NSManagedObjectContext *)context
+{
+ NSEntityDescription *entity = [NSEntityDescription entityForName:@"CMCategory" inManagedObjectContext:context];
+ self = [super initWithEntity:entity insertIntoManagedObjectContext:context];
+ return self;
+}
+
+#pragma mark - NSFetchedResultsSectionInfo properties
+
+// name is already a property
+//- (NSString *)name {}
+
+- (NSString *)indexTitle
+{
+ return self.name;
+}
+
+- (NSUInteger)numberOfObjects
+{
+ return self.items.count;
+}
+
+- (NSArray *)objects
+{
+ return self.items.array;
+}
+
+@end
23 CheckMateShopper/Models/CMItem.h
@@ -0,0 +1,23 @@
+//
+// CMItem.h
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <CoreData/CoreData.h>
+
+
+@interface CMItem : NSManagedObject
+
+@property (nonatomic, retain) NSString * itemId;
+@property (nonatomic, retain) NSString * name;
+@property (nonatomic, retain) NSManagedObject *category;
+
++ (CMItem *)findOrBuildById:(NSString *)itemId inContext:(NSManagedObjectContext *)context;
+- (id)initWithContext:(NSManagedObjectContext *)context;
+- (void)unpackDictionary:(NSDictionary *)dictionary inContext:(NSManagedObjectContext *)context;
+
+@end
53 CheckMateShopper/Models/CMItem.m
@@ -0,0 +1,53 @@
+//
+// CMItem.m
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import "CMItem.h"
+
+
+@implementation CMItem
+
+@dynamic itemId;
+@dynamic name;
+@dynamic category;
+
++ (CMItem *)findOrBuildById:(NSString *)itemId inContext:(NSManagedObjectContext *)context;
+{
+ NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"CMItem"];
+ fetchRequest.fetchLimit = 1;
+ fetchRequest.predicate = [NSPredicate predicateWithFormat:@"itemId = %@", itemId];
+
+ NSArray *results = [context executeFetchRequest:fetchRequest error:nil];
+
+ if (results.count > 0) {
+ return [results objectAtIndex:0];
+ } else {
+ return [[CMItem alloc] initWithContext:context];
+ }
+}
+
+- (id)initWithContext:(NSManagedObjectContext *)context
+{
+ NSEntityDescription *entity = [NSEntityDescription entityForName:@"CMItem" inManagedObjectContext:context];
+ self = [super initWithEntity:entity insertIntoManagedObjectContext:context];
+ return self;
+}
+
+- (void)unpackDictionary:(NSDictionary *)dictionary inContext:(NSManagedObjectContext *)context
+{
+ NSString *itemId = [[dictionary objectForKey:@"id"] stringValue];
+ NSString *itemName = [dictionary objectForKey:@"name"];
+ NSString *categoryName = [dictionary objectForKey:@"category"];
+
+ CMCategory *category = [CMCategory findOrBuildByName:categoryName inContext:context];
+
+ self.itemId = itemId;
+ self.name = itemName;
+ self.category = category;
+}
+
+@end
254 CheckMateShopper/Storyboard.storyboard
@@ -0,0 +1,254 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12C60" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="kK9-yL-ger">
+ <dependencies>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/>
+ </dependencies>
+ <scenes>
+ <!--Item List View Controller - CheckMate Shopper-->
+ <scene sceneID="Smw-Ck-PbA">
+ <objects>
+ <tableViewController id="SjS-G3-h0D" customClass="CMItemListViewController" sceneMemberID="viewController">
+ <tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="ocF-f4-et7">
+ <rect key="frame" x="0.0" y="64" width="320" height="504"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ <prototypes>
+ <tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="ItemCell" id="uk4-OB-ktc">
+ <rect key="frame" x="0.0" y="22" width="320" height="44"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
+ <rect key="frame" x="0.0" y="0.0" width="300" height="43"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+ </view>
+ <connections>
+ <segue destination="JTg-8E-WgW" kind="modal" identifier="prepareEditItemViewController:" id="fHk-8N-HLu"/>
+ </connections>
+ </tableViewCell>
+ </prototypes>
+ <connections>
+ <outlet property="dataSource" destination="SjS-G3-h0D" id="CBe-C3-N10"/>
+ <outlet property="delegate" destination="SjS-G3-h0D" id="OZy-Wy-qaQ"/>
+ </connections>
+ </tableView>
+ <navigationItem key="navigationItem" title="CheckMate Shopper" id="gDL-Pr-nbe">
+ <barButtonItem key="rightBarButtonItem" systemItem="add" id="Xbl-SY-drM">
+ <connections>
+ <segue destination="NV0-7D-xtq" kind="modal" identifier="prepareNewItemViewController:" id="rfA-2R-E6j"/>
+ </connections>
+ </barButtonItem>
+ </navigationItem>
+ <connections>
+ <outlet property="table" destination="ocF-f4-et7" id="frt-X0-FrT"/>
+ </connections>
+ </tableViewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="suI-Ca-DIb" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ </objects>
+ <point key="canvasLocation" x="543" y="90"/>
+ </scene>
+ <!--Edit Item View Controller - Edit Item-->
+ <scene sceneID="jIf-pt-G6X">
+ <objects>
+ <viewController id="JTg-8E-WgW" customClass="CMEditItemViewController" sceneMemberID="viewController">
+ <view key="view" contentMode="scaleToFill" id="eNg-jc-5Jd">
+ <rect key="frame" x="0.0" y="20" width="320" height="548"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <subviews>
+ <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Name" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="9Cf-wX-P1W">
+ <fontDescription key="fontDescription" type="system" pointSize="14"/>
+ <textInputTraits key="textInputTraits"/>
+ </textField>
+ <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Category" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="gIs-N6-JHK">
+ <fontDescription key="fontDescription" type="system" pointSize="14"/>
+ <textInputTraits key="textInputTraits"/>
+ </textField>
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bFX-O8-Emt">
+ <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
+ <state key="normal" title="Save">
+ <color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
+ <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
+ </state>
+ <state key="highlighted">
+ <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ </state>
+ <connections>
+ <action selector="save:" destination="JTg-8E-WgW" eventType="touchUpInside" id="ofe-az-Oy7"/>
+ </connections>
+ </button>
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="k7L-s2-yLL">
+ <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
+ <state key="normal" title="Delete">
+ <color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
+ <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
+ </state>
+ <state key="highlighted">
+ <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ </state>
+ <connections>
+ <action selector="deleteItem:" destination="JTg-8E-WgW" eventType="touchUpInside" id="o9V-34-mwI"/>
+ </connections>
+ </button>
+ <navigationBar contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aQN-9I-gNk">
+ <items>
+ <navigationItem title="Edit Item" id="rMz-e5-wc6">
+ <barButtonItem key="leftBarButtonItem" systemItem="cancel" id="yE6-b1-GdV">
+ <connections>
+ <action selector="cancel:" destination="JTg-8E-WgW" id="gCj-QU-sYH"/>
+ </connections>
+ </barButtonItem>
+ </navigationItem>
+ </items>
+ </navigationBar>
+ </subviews>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ <constraints>
+ <constraint firstItem="bFX-O8-Emt" firstAttribute="top" secondItem="gIs-N6-JHK" secondAttribute="bottom" constant="8" symbolic="YES" type="default" id="7aB-2f-Ya0"/>
+ <constraint firstItem="aQN-9I-gNk" firstAttribute="trailing" secondItem="eNg-jc-5Jd" secondAttribute="trailing" type="default" id="8UX-R7-wiN"/>
+ <constraint firstItem="9Cf-wX-P1W" firstAttribute="leading" secondItem="eNg-jc-5Jd" secondAttribute="leading" constant="20" symbolic="YES" type="default" id="8Z3-lb-z12"/>
+ <constraint firstAttribute="trailing" secondItem="bFX-O8-Emt" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="9fh-wa-Raa"/>
+ <constraint firstAttribute="bottom" secondItem="k7L-s2-yLL" secondAttribute="bottom" constant="20" symbolic="YES" type="default" id="A8o-hn-ybg"/>
+ <constraint firstItem="gIs-N6-JHK" firstAttribute="top" secondItem="9Cf-wX-P1W" secondAttribute="bottom" constant="8" symbolic="YES" type="default" id="JNi-3X-eeA"/>
+ <constraint firstItem="gIs-N6-JHK" firstAttribute="leading" secondItem="eNg-jc-5Jd" secondAttribute="leading" constant="20" symbolic="YES" type="default" id="UKF-Io-1Pw"/>
+ <constraint firstAttribute="trailing" secondItem="k7L-s2-yLL" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="Uxg-5A-6Ze"/>
+ <constraint firstAttribute="trailing" secondItem="9Cf-wX-P1W" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="WTl-0i-0sj"/>
+ <constraint firstAttribute="trailing" secondItem="gIs-N6-JHK" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="WnM-xH-kDX"/>
+ <constraint firstItem="aQN-9I-gNk" firstAttribute="top" secondItem="eNg-jc-5Jd" secondAttribute="top" type="default" id="YDS-MD-Nxz"/>
+ <constraint firstItem="bFX-O8-Emt" firstAttribute="leading" secondItem="eNg-jc-5Jd" secondAttribute="leading" constant="20" symbolic="YES" type="default" id="YwQ-Y5-aEQ"/>
+ <constraint firstItem="aQN-9I-gNk" firstAttribute="leading" secondItem="eNg-jc-5Jd" secondAttribute="leading" type="default" id="lAd-Dy-HIX"/>
+ <constraint firstItem="k7L-s2-yLL" firstAttribute="leading" secondItem="eNg-jc-5Jd" secondAttribute="leading" constant="20" symbolic="YES" type="default" id="rU7-YJ-cRX"/>
+ <constraint firstItem="9Cf-wX-P1W" firstAttribute="top" secondItem="eNg-jc-5Jd" secondAttribute="top" constant="68" id="yTY-qN-UnD"/>
+ </constraints>
+ </view>
+ <navigationItem key="navigationItem" title="Edit Item" id="mX5-k4-5Jt">
+ <barButtonItem key="leftBarButtonItem" systemItem="cancel" id="gKC-pp-Qaw"/>
+ </navigationItem>
+ <connections>
+ <outlet property="categoryTextField" destination="gIs-N6-JHK" id="UxC-k6-ynP"/>
+ <outlet property="nameTextField" destination="9Cf-wX-P1W" id="ctX-uF-T4v"/>
+ </connections>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="Nnx-2f-WdX" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ </objects>
+ <point key="canvasLocation" x="951" y="-578"/>
+ </scene>
+ <!--New Item View Controller-->
+ <scene sceneID="Lrb-VV-mwi">
+ <objects>
+ <viewController id="NV0-7D-xtq" customClass="CMNewItemViewController" sceneMemberID="viewController">
+ <view key="view" contentMode="scaleToFill" id="ng4-dm-idN">
+ <rect key="frame" x="0.0" y="20" width="320" height="548"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <subviews>
+ <navigationBar contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Bd8-oR-Ngi">
+ <items>
+ <navigationItem title="New Item" id="PDL-cg-BsT">
+ <barButtonItem key="leftBarButtonItem" systemItem="cancel" id="BXZ-zf-JTl">
+ <connections>
+ <action selector="cancel:" destination="NV0-7D-xtq" id="DET-R3-PuQ"/>
+ </connections>
+ </barButtonItem>
+ </navigationItem>
+ </items>
+ </navigationBar>
+ <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Name" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="dkn-90-j7z">
+ <fontDescription key="fontDescription" type="system" pointSize="14"/>
+ <textInputTraits key="textInputTraits"/>
+ </textField>
+ <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Category" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="SI1-5F-Y4U">
+ <fontDescription key="fontDescription" type="system" pointSize="14"/>
+ <textInputTraits key="textInputTraits"/>
+ </textField>
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1QS-kc-GcI">
+ <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
+ <state key="normal" title="Save">
+ <color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
+ <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
+ </state>
+ <state key="highlighted">
+ <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ </state>
+ <connections>
+ <action selector="save:" destination="NV0-7D-xtq" eventType="touchUpInside" id="6Gl-mS-xaS"/>
+ </connections>
+ </button>
+ </subviews>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ <constraints>
+ <constraint firstAttribute="trailing" secondItem="1QS-kc-GcI" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="4uq-oD-Iyp"/>
+ <constraint firstItem="SI1-5F-Y4U" firstAttribute="leading" secondItem="ng4-dm-idN" secondAttribute="leading" constant="20" symbolic="YES" type="default" id="Goy-zE-2Qg"/>
+ <constraint firstAttribute="trailing" secondItem="dkn-90-j7z" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="Nbm-ck-lfp"/>
+ <constraint firstItem="Bd8-oR-Ngi" firstAttribute="trailing" secondItem="ng4-dm-idN" secondAttribute="trailing" type="default" id="SJ1-d2-txb"/>
+ <constraint firstItem="dkn-90-j7z" firstAttribute="top" secondItem="ng4-dm-idN" secondAttribute="top" constant="66" id="V06-lt-KFF"/>
+ <constraint firstItem="1QS-kc-GcI" firstAttribute="leading" secondItem="ng4-dm-idN" secondAttribute="leading" constant="20" symbolic="YES" type="default" id="Xop-xn-rpw"/>
+ <constraint firstItem="1QS-kc-GcI" firstAttribute="top" secondItem="SI1-5F-Y4U" secondAttribute="bottom" constant="8" symbolic="YES" type="default" id="aah-wl-J3v"/>
+ <constraint firstItem="Bd8-oR-Ngi" firstAttribute="top" secondItem="ng4-dm-idN" secondAttribute="top" type="default" id="cae-Jo-DlD"/>
+ <constraint firstItem="SI1-5F-Y4U" firstAttribute="top" secondItem="dkn-90-j7z" secondAttribute="bottom" constant="8" symbolic="YES" type="default" id="dSi-yX-8d4"/>
+ <constraint firstItem="dkn-90-j7z" firstAttribute="leading" secondItem="ng4-dm-idN" secondAttribute="leading" constant="20" symbolic="YES" type="default" id="frw-xB-Hpu"/>
+ <constraint firstItem="Bd8-oR-Ngi" firstAttribute="leading" secondItem="ng4-dm-idN" secondAttribute="leading" type="default" id="ie8-mt-Nio"/>
+ <constraint firstAttribute="trailing" secondItem="SI1-5F-Y4U" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="nEH-0X-8as"/>
+ </constraints>
+ </view>
+ <navigationItem key="navigationItem" id="MiE-n9-guR">
+ <barButtonItem key="leftBarButtonItem" systemItem="cancel" id="W5L-hS-F9b"/>
+ </navigationItem>
+ <connections>
+ <outlet property="categoryTextField" destination="SI1-5F-Y4U" id="b0Q-uh-wX8"/>
+ <outlet property="nameTextField" destination="dkn-90-j7z" id="6kK-tf-sOx"/>
+ </connections>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="gtP-Bu-o7C" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ </objects>
+ <point key="canvasLocation" x="951" y="90"/>
+ </scene>
+ <!--Navigation Controller-->
+ <scene sceneID="duF-3P-Ttm">
+ <objects>
+ <navigationController definesPresentationContext="YES" id="kK9-yL-ger" sceneMemberID="viewController">
+ <navigationBar key="navigationBar" contentMode="scaleToFill" id="KHf-eg-l0r">
+ <autoresizingMask key="autoresizingMask"/>
+ </navigationBar>
+ <connections>
+ <segue destination="SjS-G3-h0D" kind="relationship" relationship="rootViewController" id="7Nn-Ih-z37"/>
+ </connections>
+ </navigationController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="x4j-75-rsi" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ </objects>
+ <point key="canvasLocation" x="133" y="90"/>
+ </scene>
+ </scenes>
+ <classes>
+ <class className="CMEditItemViewController" superclassName="UIViewController">
+ <source key="sourceIdentifier" type="project" relativePath="./Classes/CMEditItemViewController.h"/>
+ <relationships>
+ <relationship kind="action" name="cancel:"/>
+ <relationship kind="action" name="deleteItem:"/>
+ <relationship kind="action" name="save:"/>
+ <relationship kind="outlet" name="categoryTextField" candidateClass="UITextField"/>
+ <relationship kind="outlet" name="nameTextField" candidateClass="UITextField"/>
+ </relationships>
+ </class>
+ <class className="CMItemListViewController" superclassName="UITableViewController">
+ <source key="sourceIdentifier" type="project" relativePath="./Classes/CMItemListViewController.h"/>
+ <relationships>
+ <relationship kind="outlet" name="table" candidateClass="UITableView"/>
+ </relationships>
+ </class>
+ <class className="CMNewItemViewController" superclassName="UIViewController">
+ <source key="sourceIdentifier" type="project" relativePath="./Classes/CMNewItemViewController.h"/>
+ <relationships>
+ <relationship kind="action" name="cancel:"/>
+ <relationship kind="action" name="save:"/>
+ <relationship kind="outlet" name="categoryTextField" candidateClass="UITextField"/>
+ <relationship kind="outlet" name="nameTextField" candidateClass="UITextField"/>
+ </relationships>
+ </class>
+ <class className="NSLayoutConstraint" superclassName="NSObject">
+ <source key="sourceIdentifier" type="project" relativePath="./Classes/NSLayoutConstraint.h"/>
+ </class>
+ </classes>
+ <simulatedMetricsContainer key="defaultSimulatedMetrics">
+ <simulatedStatusBarMetrics key="statusBar"/>
+ <simulatedOrientationMetrics key="orientation"/>
+ <simulatedScreenMetrics key="destination" type="retina4"/>
+ </simulatedMetricsContainer>
+</document>
20 CheckMateShopper/Vendor/CMShopperHTTPClient/CMShopperHTTPClient.h
@@ -0,0 +1,20 @@
+//
+// CMShopperHTTPClient.h
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface CMShopperHTTPClient : NSObject
++ (CMShopperHTTPClient *)sharedInstance;
+- (void)listItemsOnComplete:(void(^)(NSArray *items, NSError *error))completeBlock;
+- (void)createItemWithName:(NSString *)name category:(NSString *)category onComplete:(void(^)(NSDictionary *item, NSError *error))completeBlock;
+- (void)updateItemWithId:(NSString *)itemId name:(NSString *)name category:(NSString *)category onComplete:(void(^)(NSDictionary *item, NSError *error))completeBlock;
+- (void)deleteItemWithId:(NSString *)itemId onComplete:(void(^)(NSError *error))completeBlock;
+
+//- (void)createItem:(CMItem *)item onComplete:(void(^)(CMItem *item, NSError *error))completeBlock;
+//- (void)updateItem:(CMItem *)item onComplete:(void(^)(CMItem *item, NSError *error))completeBlock;
+@end
124 CheckMateShopper/Vendor/CMShopperHTTPClient/CMShopperHTTPClient.m
@@ -0,0 +1,124 @@
+//
+// CMShopperHTTPClient.m
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import "CMShopperHTTPClient.h"
+
+@interface CMShopperHTTPClient()
+@property (nonatomic, strong) NSURL *baseUrl;
+@property (nonatomic, strong) NSString *token;
+@end
+
+@implementation CMShopperHTTPClient
+
++ (CMShopperHTTPClient *)sharedInstance
+{
+ static CMShopperHTTPClient *sharedInstance = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ sharedInstance = [[self alloc] init];
+ });
+ return sharedInstance;
+}
+
+- (id)init
+{
+ self = [super init];
+ if (self) {
+ self.baseUrl = [NSURL URLWithString:@"http://cmshopper.herokuapp.com"];
+ self.token = @"56ef17da1442a79a1011388cdb390857";
+ }
+
+ return self;
+}
+
+- (void)listItemsOnComplete:(void(^)(NSArray *items, NSError *error))completeBlock
+{
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.baseUrl URLByAppendingPathComponent:@"items.json"]];
+ request.HTTPMethod = @"GET";
+ [request setValue:self.token forHTTPHeaderField:@"X-CM-Authorization"];
+ [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
+ [request setValue:@"application/json" forHTTPHeaderField:@"Content-type"];
+
+ [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
+ if (error) {
+ completeBlock(nil, error);
+ } else {
+ NSArray *items = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
+ completeBlock(items, nil);
+ }
+ }];
+}
+
+- (void)createItemWithName:(NSString *)name category:(NSString *)category onComplete:(void(^)(NSDictionary *item, NSError *error))completeBlock
+{
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.baseUrl URLByAppendingPathComponent:@"items.json"]];
+ request.HTTPMethod = @"POST";
+ [request setValue:self.token forHTTPHeaderField:@"X-CM-Authorization"];
+ [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
+ [request setValue:@"application/json" forHTTPHeaderField:@"Content-type"];
+
+ NSDictionary *itemJsonData = [NSDictionary dictionaryWithObjectsAndKeys:name, @"name", category, @"category", nil];
+ NSDictionary *topLevelItemData = [NSDictionary dictionaryWithObject:itemJsonData forKey:@"item"];
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:topLevelItemData options:0 error:nil];
+
+ request.HTTPBody = jsonData;
+
+ [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
+ if (error) {
+ completeBlock(nil, error);
+ } else {
+ NSDictionary *item = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
+ completeBlock(item, nil);
+ }
+ }];
+}
+
+- (void)updateItemWithId:(NSString *)itemId name:(NSString *)name category:(NSString *)category onComplete:(void(^)(NSDictionary *item, NSError *error))completeBlock
+{
+ NSString *path = [NSString stringWithFormat:@"items/%@.json", itemId];
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.baseUrl URLByAppendingPathComponent:path]];
+ request.HTTPMethod = @"PUT";
+ [request setValue:self.token forHTTPHeaderField:@"X-CM-Authorization"];
+ [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
+ [request setValue:@"application/json" forHTTPHeaderField:@"Content-type"];
+
+ NSDictionary *itemJsonData = [NSDictionary dictionaryWithObjectsAndKeys:name, @"name", category, @"category", nil];
+ NSDictionary *topLevelItemData = [NSDictionary dictionaryWithObject:itemJsonData forKey:@"item"];
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:topLevelItemData options:0 error:nil];
+
+ request.HTTPBody = jsonData;
+
+ [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
+ if (error) {
+ completeBlock(nil, error);
+ } else {
+ NSDictionary *item = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
+ completeBlock(item, nil);
+ }
+ }];
+}
+
+- (void)deleteItemWithId:(NSString *)itemId onComplete:(void(^)(NSError *error))completeBlock;
+{
+ NSString *path = [NSString stringWithFormat:@"items/%@.json", itemId];
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.baseUrl URLByAppendingPathComponent:path]];
+ request.HTTPMethod = @"DELETE";
+ [request setValue:self.token forHTTPHeaderField:@"X-CM-Authorization"];
+ [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
+ [request setValue:@"application/json" forHTTPHeaderField:@"Content-type"];
+
+ [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
+ if (error) {
+ completeBlock(error);
+ } else {
+ completeBlock(nil);
+ }
+ }];
+}
+
+@end
2 CheckMateShopper/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
18 CheckMateShopper/main.m
@@ -0,0 +1,18 @@
+//
+// main.m
+// CheckMateShopper
+//
+// Created by Michael Enriquez on 2/13/13.
+// Copyright (c) 2013 Mike Enriquez. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#import "CMAppDelegate.h"
+
+int main(int argc, char *argv[])
+{
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([CMAppDelegate class]));
+ }
+}
12 README.md
@@ -0,0 +1,12 @@
+# CheckMate Shopper
+
+Sample iOS Code!
+
+## TODO
+
+* Refactor CMShopperHTTPClient. Building the request and sending it can be abstracted between the three methods.
+* Refactor new item and edit item views into a single view. The view will contain the name text field, category text field, and save button. This would also simplify validations.
+* Display an error to user on network failures.
+* Handle deletes made from other clients. This can be done by deleting all of the existing items before loading them from the server.
+* Fix animation when adding/editing.
+* Create protocol for dismissing new/edit item view controllers. They shouldn't be dismissing themselves, the parent should do that.

0 comments on commit 6f28aff

Please sign in to comment.