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
18 changes: 18 additions & 0 deletions DetailTableViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// DetailTableViewController.h
// OptionSelector
//
// Created by Kaisha Jones on 9/12/15.
// Copyright © 2015 Mike Kavouras. All rights reserved.
//

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


@interface DetailTableViewController : UITableViewController

@property (nonatomic,retain) NSIndexPath *checkedIndexPath;
@property (nonatomic) CQCategory *category;

@end
75 changes: 75 additions & 0 deletions DetailTableViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
// DetailTableViewController.m
// OptionSelector
//
// Created by Kaisha Jones on 9/12/15.
// Copyright © 2015 Mike Kavouras. All rights reserved.
//

#import "DetailTableViewController.h"

@interface DetailTableViewController ()

@end



@implementation DetailTableViewController

- (void)viewDidLoad {
[super viewDidLoad];
// set checked index path to initial value (needs to reference the selected option)
}

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

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.category.options.count; // display each category's options "sad, bliss, etc"
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DetailIdentifier" forIndexPath:indexPath];

NSString *optionName = [self.category.options objectAtIndex:indexPath.row]; // configure string to show in view
cell.textLabel.text = optionName;

if([self.category.options[indexPath.row] isEqualToString:self.category.selection]){ // added to retain selection
cell.accessoryType = UITableViewCellAccessoryCheckmark;
self.checkedIndexPath = indexPath; // added: only one checkmark is allowed!
}
return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// add check marks
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;

// to only select one item in the array
if(self.checkedIndexPath) {
UITableViewCell* uncheckCell = [tableView cellForRowAtIndexPath:self.checkedIndexPath];
uncheckCell.accessoryType = UITableViewCellAccessoryNone;
}

if([self.checkedIndexPath isEqual:indexPath]) {
self.checkedIndexPath = nil;

} else {

UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
self.checkedIndexPath = indexPath;
}
// pass data back to first array
self.category.selection = [self.category.options objectAtIndex:indexPath.row];
}

@end
28 changes: 22 additions & 6 deletions OptionSelector.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
/* Begin PBXBuildFile section */
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 */; };
8DECE7AC1B78082B0064D760 /* OptionSelectorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DECE7AB1B78082B0064D760 /* OptionSelectorTests.m */; };
A4E233DD1B7ADC98009C1E3E /* CQCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = A4E233DC1B7ADC98009C1E3E /* CQCategory.m */; };
A4E7964E1BA4C81800B6BE84 /* RootTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A4E7964D1BA4C81800B6BE84 /* RootTableViewController.m */; };
A4E796511BA4C89C00B6BE84 /* DetailTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A4E796501BA4C89C00B6BE84 /* DetailTableViewController.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -32,14 +34,19 @@
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>"; };
8DECE7A51B78082B0064D760 /* OptionSelectorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OptionSelectorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
8DECE7AA1B78082B0064D760 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8DECE7AB1B78082B0064D760 /* OptionSelectorTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OptionSelectorTests.m; sourceTree = "<group>"; };
A4E233DB1B7ADC98009C1E3E /* CQCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CQCategory.h; sourceTree = "<group>"; };
A4E233DC1B7ADC98009C1E3E /* CQCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CQCategory.m; sourceTree = "<group>"; };
A4E7964C1BA4C81800B6BE84 /* RootTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RootTableViewController.h; path = ../RootTableViewController.h; sourceTree = "<group>"; };
A4E7964D1BA4C81800B6BE84 /* RootTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RootTableViewController.m; path = ../RootTableViewController.m; sourceTree = "<group>"; };
A4E7964F1BA4C89C00B6BE84 /* DetailTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DetailTableViewController.h; path = ../DetailTableViewController.h; sourceTree = "<group>"; };
A4E796501BA4C89C00B6BE84 /* DetailTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DetailTableViewController.m; path = ../DetailTableViewController.m; sourceTree = "<group>"; };
A4E796521BA5DA4B00B6BE84 /* DetailViewControllerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailViewControllerDelegate.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -83,9 +90,14 @@
children = (
8DECE7931B78082B0064D760 /* AppDelegate.h */,
8DECE7941B78082B0064D760 /* AppDelegate.m */,
8DECE7961B78082B0064D760 /* ViewController.h */,
8DECE7971B78082B0064D760 /* ViewController.m */,
A4E233DB1B7ADC98009C1E3E /* CQCategory.h */,
A4E233DC1B7ADC98009C1E3E /* CQCategory.m */,
A4E7964C1BA4C81800B6BE84 /* RootTableViewController.h */,
A4E7964D1BA4C81800B6BE84 /* RootTableViewController.m */,
A4E7964F1BA4C89C00B6BE84 /* DetailTableViewController.h */,
A4E796501BA4C89C00B6BE84 /* DetailTableViewController.m */,
8DECE7991B78082B0064D760 /* Main.storyboard */,
A4E796521BA5DA4B00B6BE84 /* DetailViewControllerDelegate.h */,
8DECE79C1B78082B0064D760 /* Images.xcassets */,
8DECE79E1B78082B0064D760 /* LaunchScreen.xib */,
8DECE78F1B78082B0064D760 /* Supporting Files */,
Expand Down Expand Up @@ -219,9 +231,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8DECE7981B78082B0064D760 /* ViewController.m in Sources */,
A4E796511BA4C89C00B6BE84 /* DetailTableViewController.m in Sources */,
8DECE7951B78082B0064D760 /* AppDelegate.m in Sources */,
A4E233DD1B7ADC98009C1E3E /* CQCategory.m in Sources */,
8DECE7921B78082B0064D760 /* main.m in Sources */,
A4E7964E1BA4C81800B6BE84 /* RootTableViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -418,6 +432,7 @@
8DECE7B11B78082B0064D760 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
8DECE7B21B78082B0064D760 /* Build configuration list for PBXNativeTarget "OptionSelectorTests" */ = {
isa = XCConfigurationList;
Expand All @@ -426,6 +441,7 @@
8DECE7B41B78082B0064D760 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
94 changes: 78 additions & 16 deletions OptionSelector/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,25 +1,87 @@
<?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="8173.3" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="omh-Qr-RQj">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8142"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<!--Navigation Controller-->
<scene sceneID="9iH-oa-B8F">
<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">
<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"/>
<navigationController id="omh-Qr-RQj" sceneMemberID="viewController">
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina55"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="jsm-gk-mon">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="xbj-no-p6P" kind="relationship" relationship="rootViewController" id="wHd-nE-zVd"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="nX3-aT-3Bd" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-194" y="464"/>
</scene>
<!--Root Table View Controller-->
<scene sceneID="cLh-ST-aKN">
<objects>
<tableViewController id="xbj-no-p6P" customClass="RootTableViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="nWm-Kq-Jx7">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="RootTableViewIdentifier" id="nST-g5-WAr">
<rect key="frame" x="0.0" y="92" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="nST-g5-WAr" id="56e-AF-8M6">
<rect key="frame" x="0.0" y="0.0" width="414" height="43"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
<connections>
<segue destination="BOH-6n-z9Q" kind="show" identifier="rootToDetailView" id="gmd-9E-YNF"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="xbj-no-p6P" id="BIL-VB-7ee"/>
<outlet property="delegate" destination="xbj-no-p6P" id="xuG-yS-bqE"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="RoG-fs-iak"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina55"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="z9a-rf-NLV" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="504" y="438"/>
</scene>
<!--Detail Table View Controller-->
<scene sceneID="8lA-Rt-35V">
<objects>
<tableViewController storyboardIdentifier="DetailTableViewController" id="BOH-6n-z9Q" customClass="DetailTableViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="Tet-3O-eJF">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="DetailIdentifier" id="2Sa-IV-74V">
<rect key="frame" x="0.0" y="92" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2Sa-IV-74V" id="WDY-fW-JRE">
<rect key="frame" x="0.0" y="0.0" width="414" height="43"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="BOH-6n-z9Q" id="K2F-PR-Og5"/>
<outlet property="delegate" destination="BOH-6n-z9Q" id="wff-wN-8yb"/>
</connections>
</tableView>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="tcl-Dd-d9u" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1160" y="438"/>
</scene>
</scenes>
</document>
22 changes: 22 additions & 0 deletions OptionSelector/CQCategory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// CQCategory.h
// OptionSelector
//
// Created by Kaisha Jones on 8/11/15.
// Copyright (c) 2015 Mike Kavouras. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface CQCategory : NSObject // this is the class name "CQCategory"


@property (nonatomic) NSString *name; // set public property
@property (nonatomic) NSArray *options;
@property (nonatomic) NSString *selection;

- (instancetype)initWithCategoryType:(NSString *)type;

//-(void) initializeData;

@end
Loading