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
70 changes: 6 additions & 64 deletions VaultCodeTest.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
11BB01302086A0CE0073C1D1 /* NSString+Remove.m in Sources */ = {isa = PBXBuildFile; fileRef = 11BB012F2086A0CE0073C1D1 /* NSString+Remove.m */; };
7F5A90D2C4103D3206133DB0 /* libPods-VaultCodeTestTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E2A89628BEAD9BA5B75ABD1B /* libPods-VaultCodeTestTests.a */; };
E1F67E0F2073D43B00DB272D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E1F67E0E2073D43B00DB272D /* AppDelegate.m */; };
E1F67E122073D43B00DB272D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E1F67E112073D43B00DB272D /* ViewController.m */; };
Expand Down Expand Up @@ -39,6 +40,8 @@
/* Begin PBXFileReference section */
064B29C7A8542B1A25225FC4 /* Pods-VaultCodeTest.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VaultCodeTest.debug.xcconfig"; path = "Pods/Target Support Files/Pods-VaultCodeTest/Pods-VaultCodeTest.debug.xcconfig"; sourceTree = "<group>"; };
0F93E4D7F0DF9446E8F1335A /* Pods-VaultCodeTestTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VaultCodeTestTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-VaultCodeTestTests/Pods-VaultCodeTestTests.debug.xcconfig"; sourceTree = "<group>"; };
11BB012E2086A0CE0073C1D1 /* NSString+Remove.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "NSString+Remove.h"; path = "Extensions/NSString+Remove.h"; sourceTree = "<group>"; };
11BB012F2086A0CE0073C1D1 /* NSString+Remove.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "NSString+Remove.m"; path = "Extensions/NSString+Remove.m"; sourceTree = "<group>"; };
213FE0C287ACBAD6BABFD745 /* Pods-VaultCodeTest.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VaultCodeTest.release.xcconfig"; path = "Pods/Target Support Files/Pods-VaultCodeTest/Pods-VaultCodeTest.release.xcconfig"; sourceTree = "<group>"; };
62A2E7A33FF0E66DCF6E23E6 /* libPods-VaultCodeTest.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-VaultCodeTest.a"; sourceTree = BUILT_PRODUCTS_DIR; };
E1F67E0A2073D43B00DB272D /* VaultCodeTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VaultCodeTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -137,6 +140,8 @@
E1F67E0E2073D43B00DB272D /* AppDelegate.m */,
E1F67E102073D43B00DB272D /* ViewController.h */,
E1F67E112073D43B00DB272D /* ViewController.m */,
11BB012E2086A0CE0073C1D1 /* NSString+Remove.h */,
11BB012F2086A0CE0073C1D1 /* NSString+Remove.m */,
E1F67E132073D43B00DB272D /* Main.storyboard */,
E1F67E162073D43B00DB272D /* Assets.xcassets */,
E1F67E182073D43B00DB272D /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -175,8 +180,6 @@
E1F67E062073D43B00DB272D /* Sources */,
E1F67E072073D43B00DB272D /* Frameworks */,
E1F67E082073D43B00DB272D /* Resources */,
6FE68FF0FE47869B1519C47A /* [CP] Embed Pods Frameworks */,
09E4CF660F01B99F0FBB01FD /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -195,8 +198,6 @@
E1F67E1E2073D43B00DB272D /* Sources */,
E1F67E1F2073D43B00DB272D /* Frameworks */,
E1F67E202073D43B00DB272D /* Resources */,
9044756752E26EEC25B06432 /* [CP] Embed Pods Frameworks */,
FDC085E49CCF080A17244F77 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -299,21 +300,6 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
09E4CF660F01B99F0FBB01FD /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-VaultCodeTest/Pods-VaultCodeTest-resources.sh\"\n";
showEnvVarsInLog = 0;
};
3F42EDF1754853F6B0E04A1F /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -332,36 +318,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
6FE68FF0FE47869B1519C47A /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-VaultCodeTest/Pods-VaultCodeTest-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9044756752E26EEC25B06432 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-VaultCodeTestTests/Pods-VaultCodeTestTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
B82348C9036591DF23B53339 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -380,21 +336,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
FDC085E49CCF080A17244F77 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-VaultCodeTestTests/Pods-VaultCodeTestTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand All @@ -403,6 +344,7 @@
buildActionMask = 2147483647;
files = (
E1F67E122073D43B00DB272D /* ViewController.m in Sources */,
11BB01302086A0CE0073C1D1 /* NSString+Remove.m in Sources */,
E1F67E1D2073D43B00DB272D /* main.m in Sources */,
E1F67E0F2073D43B00DB272D /* AppDelegate.m in Sources */,
);
Expand Down
12 changes: 8 additions & 4 deletions VaultCodeTest/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -36,8 +36,11 @@
<rect key="frame" x="132" y="130" width="111" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Load Image"/>
<connections>
<action selector="loadImageAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="4mc-2n-k59"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YKv-D3-Q5U">
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YKv-D3-Q5U">
<rect key="frame" x="67" y="168" width="240" height="128"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
Expand All @@ -46,7 +49,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Reverse String"/>
<connections>
<action selector="processString:" destination="BYZ-38-t0r" eventType="touchDown" id="J31-UV-oC1"/>
<action selector="processString:" destination="BYZ-38-t0r" eventType="touchUpInside" id="hC5-Id-AKN"/>
</connections>
</button>
</subviews>
Expand All @@ -55,6 +58,7 @@
</view>
<connections>
<outlet property="imageView" destination="YKv-D3-Q5U" id="cUV-91-oSj"/>
<outlet property="loadImageButton" destination="K2H-H9-Kdq" id="ays-9c-A51"/>
<outlet property="textDest" destination="6a8-QR-JdA" id="9vJ-pI-3RN"/>
<outlet property="textSrc" destination="KHX-dg-iEW" id="f8j-cF-AVr"/>
</connections>
Expand Down
13 changes: 13 additions & 0 deletions VaultCodeTest/Extensions/NSString+Remove.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// NSString+NSString_Remove.h
// VaultCodeTest
//
// Created by Michael Steele on 4/17/18.
// Copyright © 2018 Vault. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSString (Remove)
-(NSString *)reverse;
@end
23 changes: 23 additions & 0 deletions VaultCodeTest/Extensions/NSString+Remove.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// NSString+NSString_Remove.m
// VaultCodeTest
//
// Created by Michael Steele on 4/17/18.
// Copyright © 2018 Vault. All rights reserved.
//

#import "NSString+Remove.h"

@implementation NSString (Remove)

-(NSString *)reverse {
NSMutableString *textReversedString = [[NSMutableString alloc] init];

[self enumerateSubstringsInRange:NSMakeRange(0,[self length])
options:(NSStringEnumerationReverse | NSStringEnumerationByComposedCharacterSequences)
usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
[textReversedString appendString:substring];
}];
return textReversedString;
}
@end
1 change: 1 addition & 0 deletions VaultCodeTest/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@property (weak, nonatomic) IBOutlet UITextField *textSrc;
@property (weak, nonatomic) IBOutlet UITextField *textDest;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UIButton *loadImageButton;

@end

25 changes: 24 additions & 1 deletion VaultCodeTest/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
//

#import "ViewController.h"
#import <AFNetworking/AFNetworking.h>
#import <AFNetworking/AFImageDownloader.h>
#import "NSString+Remove.h"

@interface ViewController ()

@end

@implementation ViewController
Expand All @@ -27,5 +29,26 @@ - (void)didReceiveMemoryWarning {

- (IBAction)processString:(id)sender {
// Reverse string in textSrc and assign to textDest here

[_textDest setText:[[_textSrc text] reverse]];
}

- (IBAction)loadImageAction:(id)sender {

AFImageDownloader* imageDownloader = [[AFImageDownloader alloc] init];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString: @"https://thecatapi.com/api/images/get?format=src&type=png"]];

[imageDownloader downloadImageForURLRequest:request success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
NSLog(@"Success: Image downloaded.");
CGRect lastFrame = [_loadImageButton frame];
CGRect viewFrame = [[self view] frame];
CGFloat offset = lastFrame.size.height;
CGRect imageFrame = CGRectMake(viewFrame.origin.x, lastFrame.origin.y + offset, viewFrame.size.width, viewFrame.size.height - lastFrame.origin.y - offset);
[_imageView setFrame: imageFrame];
[_imageView setImage: responseObject];

} failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
NSLog(@"Failed to download image.");
}];
}
@end
3 changes: 2 additions & 1 deletion VaultCodeTestTests/VaultCodeTestTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import <XCTest/XCTest.h>
#import "ViewController.h"
#import "NSString+Remove.h"

@interface VaultCodeTestTests : XCTestCase

Expand All @@ -27,7 +28,7 @@ - (void)testReverseString {
NSString *src = @"abc123";
NSString *result = @"321cba";

NSString *test = @""; // Assign result of string reversal function here
NSString *test = [src reverse]; // Assign result of string reversal function here

XCTAssertTrue([result isEqualToString:test]);
}
Expand Down