Skip to content

Commit

Permalink
Initial 1.0 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
joshc89 committed Apr 27, 2016
0 parents commit aa1ad44
Show file tree
Hide file tree
Showing 134 changed files with 24,256 additions and 0 deletions.
177 changes: 177 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.1
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2013 updates:
# - fixed the broken "save personal Schemes"
# - added line-by-line explanations for EVERYTHING (some were missing)
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
#########################

#####
# OS X temporary files that should never be committed
#
# c.f. http://www.westwind.com/reference/os-x/invisibles.html

.DS_Store

# c.f. http://www.westwind.com/reference/os-x/invisibles.html

.Trashes

# c.f. http://www.westwind.com/reference/os-x/invisibles.html

*.swp

# *.lock - this is used and abused by many editors for many different things.
# For the main ones I use (e.g. Eclipse), it should be excluded
# from source-control, but YMMV

*.lock

#
# profile - REMOVED temporarily (on double-checking, this seems incorrect; I can't find it in OS X docs?)
#profile


####
# Xcode temporary files that should never be committed
#
# NB: NIB/XIB files still exist even on Storyboard projects, so we want this...

*~.nib


####
# Xcode build files -
#
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData"

DerivedData/

# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build"

build/


#####
# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups)
#
# This is complicated:
#
# SOMETIMES you need to put this file in version control.
# Apple designed it poorly - if you use "custom executables", they are
# saved in this file.
# 99% of projects do NOT use those, so they do NOT want to version control this file.
# ..but if you're in the 1%, comment out the line "*.pbxuser"

# .pbxuser: http://lists.apple.com/archives/xcode-users/2004/Jan/msg00193.html

*.pbxuser

# .mode1v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html

*.mode1v3

# .mode2v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html

*.mode2v3

# .perspectivev3: http://stackoverflow.com/questions/5223297/xcode-projects-what-is-a-perspectivev3-file

*.perspectivev3

# NB: also, whitelist the default ones, some projects need to use these
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3


####
# Xcode 4 - semi-personal settings
#
#
# OPTION 1: ---------------------------------
# throw away ALL personal settings (including custom schemes!
# - unless they are "shared")
#
# NB: this is exclusive with OPTION 2 below
xcuserdata

# OPTION 2: ---------------------------------
# get rid of ALL personal settings, but KEEP SOME OF THEM
# - NB: you must manually uncomment the bits you want to keep
#
# NB: this *requires* git v1.8.2 or above; you may need to upgrade to latest OS X,
# or manually install git over the top of the OS X version
# NB: this is exclusive with OPTION 1 above
#
#xcuserdata/**/*

# (requires option 2 above): Personal Schemes
#
#!xcuserdata/**/xcschemes/*

####
# XCode 4 workspaces - more detailed
#
# Workspaces are important! They are a core feature of Xcode - don't exclude them :)
#
# Workspace layout is quite spammy. For reference:
#
# /(root)/
# /(project-name).xcodeproj/
# project.pbxproj
# /project.xcworkspace/
# contents.xcworkspacedata
# /xcuserdata/
# /(your name)/xcuserdatad/
# UserInterfaceState.xcuserstate
# /xcsshareddata/
# /xcschemes/
# (shared scheme name).xcscheme
# /xcuserdata/
# /(your name)/xcuserdatad/
# (private scheme).xcscheme
# xcschememanagement.plist
#
#

####
# Xcode 4 - Deprecated classes
#
# Allegedly, if you manually "deprecate" your classes, they get moved here.
#
# We're using source-control, so this is a "feature" that we do not want!

*.moved-aside

####
# Xcode 5 - VCS file
# The data in this file not represent state of your project.
# If you'll leave this file in git - you will have merge conflicts during
# pull your cahnges to other's repo
#
*.xccheckout

####
# Ignore pods directory and other related files
*.lock
Pods/

####
# UNKNOWN: recommended by others, but I can't discover what these files are
#
# ...none. Everything is now explained.
8 changes: 8 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016 The Distance

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
58 changes: 58 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# TheDistanceCore

[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
![MIT license](https://img.shields.io/badge/license-MIT-lightgrey.svg)

Develop faster with convenience functions from The Distance.

## Requirements

- iOS 8.0+
- Xcode 7.3
- Swift 2.2

## Features

Reducing boilerplate code helps us to develop features faster and ensure they remain bug free, with platform updates and so we don't forget tricky edge cases.

**TheDistanceCore** contains simple extensions and reusable classes that are references in multiple projects. The purpose of this project is to contain small pieces of functionality that are very general. More specific code, or code that has dependencies on other frameworks, should not be included here.

Functionality includes:

- **Parallax Scroll**: Standard Protocol for implementing a 'parallax scroll' where one view moves based on a `UIScrollView`'s content offset.
- **Storyboard Loader**: Storyboards can easily become bloated and slow to load. Typically storyboards can be separated into related parts but managing which View Controller is where can be messy if done throughout the app. The `StoryboardLoader` protocol simplifies this by allowing you to define enums for your Storyboards and ViewControllers and instantiate them using `StoryboardLoader.instantiateViewControllerWithIdentifier(_:)`.
- **Pure Swift Key-Value-Observing**: `NSObject`s implement a method called `methodSignatureForSelector:` which converts from strings to methods. Pure Swift classes do not have this method so cannot inherently perform KVO or observe `NSNotificationCenter` posts. `Observer`, `ObjectObserver`, and `NotificationObserver` resolve this.
- **NSLayoutConstraints**: The default `NSLayoutConstraint` initialisers are clear but can be cumbersome when creating standard constraints. `constraintsToSize(...)` and `constraintsToAlign(...)` neaten the programmatic constraint creation process. Other convenience initialisers are provided.
- **Request Cache Control**: Not all APIs respond with 304 unmodified states when making requests with the `if-modified-since` header. It can be useful to impose a fixed time limit between the same network requests. The `RequestCache` protocol simplifies checking time intervals since successful requests.
- **Extension Framework**: Framework version with API restricted to that suitable for an extension.

Other features include:

- User friendly `NSError`s from networking and location operations.
- Neater syntax for Swift Dictionary creation when using `.map({ ... })`.
- Shortened Syntax for whitespace trimmed Strings.
- Simplified URL opening for Google Chrome or Safari.
- Default date comparisons using comparison operators.
- Standard device dependent rotations (iPhone +s and iPads rotate `.AllButUpsideDown`, iPhones locked to portrait)
- `CGRect`, `UIEdgeInsets` common calculations.


## Communication

- If you have **found a bug**, open an issue.
- If you have **a feature request**, open an issue.
- If you **want to contribute**, submit a pull request.
- If you'd like to **ask a general question**, email <[email protected]>.

## Installation

[Carthage](https://github.com/Carthage/Carthage) is the preferred dependency manager as it reduces build times during app development. TheDistanceCore has been built for Carthage. Add

github "TheDistance/TheDistanceCore"

to your cartfile and run

carthage update TheDistanceCore

to build the framework. Add to it your project according to the Carthage instructions.

26 changes: 26 additions & 0 deletions TDCore-Extension/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
19 changes: 19 additions & 0 deletions TDCore-Extension/TDCore-Extension.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// TDCore-Extension.h
// TDCore-Extension
//
// Created by Josh Campion on 05/04/2016.
// Copyright © 2016 The Distance. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for TDCore-Extension.
FOUNDATION_EXPORT double TDCore_ExtensionVersionNumber;

//! Project version string for TDCore-Extension.
FOUNDATION_EXPORT const unsigned char TDCore_ExtensionVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <TDCore_Extension/PublicHeader.h>


52 changes: 52 additions & 0 deletions TDCore-Extension/UIViewController-Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// UIViewController-Extension.swift
// TDCore
//
// Created by Josh Campion on 05/04/2016.
// Copyright © 2016 The Distance. All rights reserved.
//

import UIKit

public extension UIViewController {

/// - returns: Whether or not the shared `UIApplication` can open the given `NSURL`.
public func canOpenURL(url:NSURL) -> Bool {

var responder = self.nextResponder()
while responder != nil {

if responder is UIApplication {
break
} else {
responder = responder?.nextResponder()
}
}

if let application = responder as? UIApplication {
let result = application.performSelector(Selector("number_canOpenURL:"), withObject: url)
return (result?.takeUnretainedValue() as? Bool) ?? false
}

return false
}

public func openURL(url:NSURL) {

var responder = self.nextResponder()
while responder != nil {

if responder is UIApplication {
break
} else {
responder = responder?.nextResponder()
}
}

if let application = responder as? UIApplication {
application.performSelector(Selector("openURL:"), withObject: url)
return
}
}

}
24 changes: 24 additions & 0 deletions TDCore-ExtensionTests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Loading

0 comments on commit aa1ad44

Please sign in to comment.