Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions OptionSelector.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
objects = {

/* Begin PBXBuildFile section */
6B01EF871B7D1B34004151ED /* CQShadesData.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B01EF861B7D1B34004151ED /* CQShadesData.m */; };
6B9A63F41B7A9D4E0025CD30 /* CategoriesRootViewTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B9A63F31B7A9D4E0025CD30 /* CategoriesRootViewTableViewController.m */; };
6B9A63F71B7A9DA20025CD30 /* ListTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B9A63F61B7A9DA20025CD30 /* ListTableViewController.m */; };
6BB571A31B7ADDBB0065EE52 /* CQCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BB571A21B7ADDBB0065EE52 /* CQCategory.m */; };
8DECE7921B78082B0064D760 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DECE7911B78082B0064D760 /* main.m */; };
8DECE7951B78082B0064D760 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DECE7941B78082B0064D760 /* AppDelegate.m */; };
8DECE7981B78082B0064D760 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DECE7971B78082B0064D760 /* ViewController.m */; };
8DECE79B1B78082B0064D760 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8DECE7991B78082B0064D760 /* Main.storyboard */; };
8DECE79D1B78082B0064D760 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8DECE79C1B78082B0064D760 /* Images.xcassets */; };
8DECE7A01B78082B0064D760 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8DECE79E1B78082B0064D760 /* LaunchScreen.xib */; };
Expand All @@ -27,13 +30,19 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
6B01EF851B7D1B34004151ED /* CQShadesData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CQShadesData.h; sourceTree = "<group>"; };
6B01EF861B7D1B34004151ED /* CQShadesData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CQShadesData.m; sourceTree = "<group>"; };
6B9A63F21B7A9D4E0025CD30 /* CategoriesRootViewTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CategoriesRootViewTableViewController.h; sourceTree = "<group>"; };
6B9A63F31B7A9D4E0025CD30 /* CategoriesRootViewTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CategoriesRootViewTableViewController.m; sourceTree = "<group>"; };
6B9A63F51B7A9DA20025CD30 /* ListTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListTableViewController.h; sourceTree = "<group>"; };
6B9A63F61B7A9DA20025CD30 /* ListTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ListTableViewController.m; sourceTree = "<group>"; };
6BB571A11B7ADDBB0065EE52 /* CQCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CQCategory.h; sourceTree = "<group>"; };
6BB571A21B7ADDBB0065EE52 /* CQCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CQCategory.m; sourceTree = "<group>"; };
8DECE78C1B78082B0064D760 /* OptionSelector.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OptionSelector.app; sourceTree = BUILT_PRODUCTS_DIR; };
8DECE7901B78082B0064D760 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8DECE7911B78082B0064D760 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
8DECE7931B78082B0064D760 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
8DECE7941B78082B0064D760 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
8DECE7961B78082B0064D760 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
8DECE7971B78082B0064D760 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
8DECE79A1B78082B0064D760 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
8DECE79C1B78082B0064D760 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
8DECE79F1B78082B0064D760 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -83,8 +92,14 @@
children = (
8DECE7931B78082B0064D760 /* AppDelegate.h */,
8DECE7941B78082B0064D760 /* AppDelegate.m */,
8DECE7961B78082B0064D760 /* ViewController.h */,
8DECE7971B78082B0064D760 /* ViewController.m */,
6B01EF851B7D1B34004151ED /* CQShadesData.h */,
6B01EF861B7D1B34004151ED /* CQShadesData.m */,
6BB571A11B7ADDBB0065EE52 /* CQCategory.h */,
6BB571A21B7ADDBB0065EE52 /* CQCategory.m */,
6B9A63F21B7A9D4E0025CD30 /* CategoriesRootViewTableViewController.h */,
6B9A63F31B7A9D4E0025CD30 /* CategoriesRootViewTableViewController.m */,
6B9A63F51B7A9DA20025CD30 /* ListTableViewController.h */,
6B9A63F61B7A9DA20025CD30 /* ListTableViewController.m */,
8DECE7991B78082B0064D760 /* Main.storyboard */,
8DECE79C1B78082B0064D760 /* Images.xcassets */,
8DECE79E1B78082B0064D760 /* LaunchScreen.xib */,
Expand Down Expand Up @@ -219,9 +234,12 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8DECE7981B78082B0064D760 /* ViewController.m in Sources */,
8DECE7951B78082B0064D760 /* AppDelegate.m in Sources */,
6B9A63F41B7A9D4E0025CD30 /* CategoriesRootViewTableViewController.m in Sources */,
6BB571A31B7ADDBB0065EE52 /* CQCategory.m in Sources */,
6B01EF871B7D1B34004151ED /* CQShadesData.m in Sources */,
8DECE7921B78082B0064D760 /* main.m in Sources */,
6B9A63F71B7A9DA20025CD30 /* ListTableViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -418,6 +436,7 @@
8DECE7B11B78082B0064D760 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
8DECE7B21B78082B0064D760 /* Build configuration list for PBXNativeTarget "OptionSelectorTests" */ = {
isa = XCConfigurationList;
Expand All @@ -426,6 +445,7 @@
8DECE7B41B78082B0064D760 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
107 changes: 92 additions & 15 deletions OptionSelector/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,25 +1,102 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="yHh-TO-TBS">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<!--Root View Controller-->
<scene sceneID="A5M-Xt-RcU">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<tableViewController id="ies-nT-E3N" customClass="CategoriesRootViewTableViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="Y4C-In-wmf">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="ColorThesaurusIdentifier" textLabel="yIU-Ez-kN7" detailTextLabel="Tyy-Lo-ptm" rowHeight="200" style="IBUITableViewCellStyleValue1" id="HNi-SL-atG">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="HNi-SL-atG" id="cQL-7x-0vF">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="yIU-Ez-kN7">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Tyy-Lo-ptm">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="84C-4i-w7q" kind="show" id="Ct4-bZ-ume"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="ies-nT-E3N" id="JCe-6Y-gZL"/>
<outlet property="delegate" destination="ies-nT-E3N" id="Ji2-ZL-rfI"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Root View Controller" id="MEk-cr-JB2"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="02s-6d-1KN" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="712" y="460"/>
</scene>
<!--List Table View Controller-->
<scene sceneID="iM8-ep-Y7g">
<objects>
<tableViewController id="84C-4i-w7q" customClass="ListTableViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="lFC-5Z-xJ3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="ListOfShadesCellIdentifier" textLabel="1P7-tJ-8Tf" style="IBUITableViewCellStyleDefault" id="Cy9-53-DOP">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Cy9-53-DOP" id="o93-PZ-D7O">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1P7-tJ-8Tf">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="84C-4i-w7q" id="mPx-6B-HEX"/>
<outlet property="delegate" destination="84C-4i-w7q" id="sof-RL-0pz"/>
</connections>
</tableView>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="l0x-3o-Y3F" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1396" y="460"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="TMN-kr-guX">
<objects>
<navigationController id="yHh-TO-TBS" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="sFn-nT-BgJ">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="ies-nT-E3N" kind="relationship" relationship="rootViewController" id="YtN-Z8-mIm"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Wmq-jl-5ae" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-108" y="460"/>
</scene>
</scenes>
</document>
26 changes: 26 additions & 0 deletions OptionSelector/CQCategory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// CQCategory.h
// OptionSelector
//
// Created by Justine Gartner on 8/11/15.
// Copyright (c) 2015 Mike Kavouras. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

//Model class for a category and it's related items/options. Every category has an array of options to choose from. Every array of options has a corresponding array of shade colors. Selected options and selected shade colors are selected by user.
@interface CQCategory : NSObject

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good practice to include at least one comment for each class describing what it does or what data it stores (if it's just a data storage class). Even if it seems obvious to you now, it might not in a month (and it might not to your colleagues).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! 👍


@property (nonatomic) NSString *name;
@property (nonatomic) NSString *detailTitle;
@property (nonatomic) NSArray *options;
@property (nonatomic) NSArray *shadeColors;
@property (nonatomic) NSString *selectedOption;
@property (nonatomic) UIColor *selectedShadeColor;

-(void)saveSelection;

-(void)loadDefaults;

@end
47 changes: 47 additions & 0 deletions OptionSelector/CQCategory.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// CQCategory.m
// OptionSelector
//
// Created by Justine Gartner on 8/11/15.
// Copyright (c) 2015 Mike Kavouras. All rights reserved.
//

#define SelectedOptionKey @"SelectedOptionName"
#define SelectedColorKey @"SelectedColor"

#import "CQCategory.h"

@implementation CQCategory

-(void)saveSelection{

//archive the UIColor into NSData
NSData *colorData = [NSKeyedArchiver archivedDataWithRootObject:self.selectedShadeColor];

//create a dictionary with the selectedOption and selectedShadeColor
NSDictionary *data = @{SelectedOptionKey : self.selectedOption,
SelectedColorKey : colorData
};
//store the dictionary in NSUserDefaults with the key: self.name
[[NSUserDefaults standardUserDefaults] setObject:data forKey:self.name];

}

-(void)loadDefaults{

//load dictionary from NSUserDefaluts for the key: self.name
NSDictionary *data = [[NSUserDefaults standardUserDefaults] objectForKey:self.name];

//access the alue for the key color (NSData)
NSData *colorData = data[SelectedColorKey];

//convert the color data (NSData) to a color object (UIColor)
UIColor *color = [NSKeyedUnarchiver unarchiveObjectWithData:colorData];

if (data != nil) {
self.selectedOption = data[SelectedOptionKey];
self.selectedShadeColor = color;
}
}

@end
22 changes: 22 additions & 0 deletions OptionSelector/CQShadesData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// CQShadesData.h
// OptionSelector
//
// Created by Justine Gartner on 8/13/15.
// Copyright (c) 2015 Mike Kavouras. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CQCategory.h"


//Initializes data for categories of shades from CQCategory class
@interface CQShadesData : NSObject

@property (nonatomic) CQCategory *red;
@property (nonatomic) CQCategory *blue;
@property (nonatomic) CQCategory *yellow;

-(void)initializeData;

@end
Loading