Skip to content

Commit

Permalink
Update project to iOS 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Oliveira committed May 25, 2015
1 parent 59481f2 commit 19d4fcf
Show file tree
Hide file tree
Showing 22 changed files with 121 additions and 97 deletions.
16 changes: 9 additions & 7 deletions VIPER-SWIFT/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6154.17" systemVersion="14A238x" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="F64-Qc-pGf">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E17e" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="F64-Qc-pGf">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6153.11"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
Expand Down Expand Up @@ -36,21 +36,23 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="empty" translatesAutoresizingMaskIntoConstraints="NO" id="IUm-Nr-pH8">
<rect key="frame" x="80" y="204" width="160" height="160"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="IUm-Nr-pH8" firstAttribute="centerX" secondItem="LnP-t5-94n" secondAttribute="centerX" id="gRj-qi-rft"/>
<constraint firstItem="IUm-Nr-pH8" firstAttribute="centerY" secondItem="LnP-t5-94n" secondAttribute="centerY" id="kx6-eL-hJB"/>
<constraint firstItem="IUm-Nr-pH8" firstAttribute="top" secondItem="LnP-t5-94n" secondAttribute="top" id="PzM-nb-Pkl"/>
<constraint firstItem="IUm-Nr-pH8" firstAttribute="leading" secondItem="LnP-t5-94n" secondAttribute="leading" id="YwI-Zb-0Ov"/>
<constraint firstAttribute="trailing" secondItem="IUm-Nr-pH8" secondAttribute="trailing" id="jMv-1S-TcB"/>
<constraint firstAttribute="bottom" secondItem="IUm-Nr-pH8" secondAttribute="bottom" id="rQW-eL-fsK"/>
</constraints>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="Dwl-V3-Jpn">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" ambiguous="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="ListEntryCell" textLabel="NBj-2E-azl" detailTextLabel="1oT-NU-IFa" style="IBUITableViewCellStyleValue1" id="Rhp-dv-i8T">
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ListEntryCell" textLabel="NBj-2E-azl" detailTextLabel="1oT-NU-IFa" style="IBUITableViewCellStyleValue1" id="Rhp-dv-i8T">
<rect key="frame" x="0.0" y="55" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Rhp-dv-i8T" id="gVg-IG-mur">
Expand Down Expand Up @@ -133,7 +135,7 @@
<datePicker contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" datePickerMode="date" minuteInterval="1" translatesAutoresizingMaskIntoConstraints="NO" id="gW8-Uc-U23">
<rect key="frame" x="0.0" y="102" width="260" height="162"/>
<date key="date" timeIntervalSinceReferenceDate="422464776.95016199">
<!--<__NSDate Class=2014-05-22 15:19:36 +0000 timeInterval=422464776.950162 ISO8601=2014-05-22T08:19:36.950-0700>-->
<!--2014-05-22 15:19:36 +0000-->
</date>
</datePicker>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Due Date" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hIS-VJ-zb9">
Expand Down
4 changes: 2 additions & 2 deletions VIPER-SWIFT/Classes/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

let appDependencies = AppDependencies()

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
appDependencies.installRootViewControllerIntoWindow(window!)

return true
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

extension NSCalendar {
class func gregorianCalendar() -> NSCalendar {
return NSCalendar(calendarIdentifier: NSGregorianCalendar)
return NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
}

func dateWithYear(year: Int, month: Int, day: Int) -> NSDate {
Expand All @@ -19,40 +19,40 @@ extension NSCalendar {
components.month = month
components.day = day
components.hour = 12
return dateFromComponents(components)
return dateFromComponents(components)!
}

func dateForTomorrowRelativeToToday(today: NSDate) -> NSDate {
let tomorrowComponents = NSDateComponents()
tomorrowComponents.day = 1
return dateByAddingComponents(tomorrowComponents, toDate: today, options: nil)
return dateByAddingComponents(tomorrowComponents, toDate: today, options: nil)!
}

func dateForEndOfWeekWithDate(date: NSDate) -> NSDate {
let daysRemainingThisWeek = daysRemainingInWeekWithDate(date)
let remainingDaysComponent = NSDateComponents()
remainingDaysComponent.day = daysRemainingThisWeek
return dateByAddingComponents(remainingDaysComponent, toDate: date, options: nil)
return dateByAddingComponents(remainingDaysComponent, toDate: date, options: nil)!
}

func dateForBeginningOfDay(date: NSDate) -> NSDate {
let newComponent = components((NSCalendarUnit.YearCalendarUnit | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay), fromDate: date)
let newComponent = components(.CalendarUnitYear | .CalendarUnitMonth | .CalendarUnitDay, fromDate: date)
let newDate = dateFromComponents(newComponent)
return newDate
return newDate!
}

func dateForEndOfDay(date: NSDate) -> NSDate {
let components = NSDateComponents()
components.day = 1
let toDate = dateForBeginningOfDay(date)
let nextDay = dateByAddingComponents(components, toDate: toDate, options: nil)
let endDay = nextDay.dateByAddingTimeInterval(-1)
return nextDay
let endDay = nextDay!.dateByAddingTimeInterval(-1)
return nextDay!
}

func daysRemainingInWeekWithDate(date: NSDate) -> Int {
let weekdayComponent = components(NSCalendarUnit.WeekdayCalendarUnit, fromDate: date)
let daysRange = rangeOfUnit(NSCalendarUnit.WeekdayCalendarUnit, inUnit: NSCalendarUnit.WeekCalendarUnit, forDate: date)
let weekdayComponent = components(.CalendarUnitWeekday, fromDate: date)
let daysRange = rangeOfUnit(.CalendarUnitWeekday, inUnit: .CalendarUnitWeekOfMonth, forDate: date)
let daysPerWeek = daysRange.length
let daysRemaining = daysPerWeek - weekdayComponent.weekday
return daysRemaining
Expand All @@ -61,9 +61,9 @@ extension NSCalendar {
func dateForEndOfFollowingWeekWithDate(date: NSDate) -> NSDate {
let endOfWeek = dateForEndOfWeekWithDate(date)
let nextWeekComponent = NSDateComponents()
nextWeekComponent.setWeek(1)
nextWeekComponent.weekOfYear = 1
let followingWeekDate = dateByAddingComponents(nextWeekComponent, toDate: endOfWeek, options: nil)
return followingWeekDate
return followingWeekDate!
}

func isDate(date: NSDate, beforeYearMonthDay: NSDate) -> Bool {
Expand All @@ -79,17 +79,17 @@ extension NSCalendar {
}

func isDate(date: NSDate, duringSameWeekAsDate: NSDate) -> Bool {
let dateComponents = components(NSCalendarUnit.WeekCalendarUnit, fromDate: date)
let duringSameWeekComponents = components(NSCalendarUnit.WeekCalendarUnit, fromDate: duringSameWeekAsDate)
let result = dateComponents.week() == duringSameWeekComponents.week()
let dateComponents = components(.CalendarUnitWeekOfMonth, fromDate: date)
let duringSameWeekComponents = components(.CalendarUnitWeekOfMonth, fromDate: duringSameWeekAsDate)
let result = dateComponents.weekOfMonth == duringSameWeekComponents.weekOfMonth
return result
}

func isDate(date: NSDate, duringWeekAfterDate: NSDate) -> Bool {
let nextWeek = dateForEndOfFollowingWeekWithDate(duringWeekAfterDate)
let dateComponents = components(NSCalendarUnit.WeekCalendarUnit, fromDate: date)
let nextWeekComponents = components(NSCalendarUnit.WeekCalendarUnit, fromDate: nextWeek)
let result = dateComponents.week() == nextWeekComponents.week()
let dateComponents = components(.CalendarUnitWeekOfMonth, fromDate: date)
let nextWeekComponents = components(.CalendarUnitWeekOfMonth, fromDate: nextWeek)
let result = dateComponents.weekOfMonth == nextWeekComponents.weekOfMonth
return result
}

Expand All @@ -111,7 +111,7 @@ extension NSCalendar {
}

func yearMonthDayComponentsFromDate(date: NSDate) -> NSDateComponents {
let newComponents = components((NSCalendarUnit.YearCalendarUnit | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitDay), fromDate: date)
let newComponents = components(.CalendarUnitYear | .CalendarUnitMonth | .CalendarUnitDay, fromDate: date)
return newComponents
}

Expand Down
12 changes: 6 additions & 6 deletions VIPER-SWIFT/Classes/Common/Store/CoreDataStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class CoreDataStore : NSObject {
var managedObjectModel : NSManagedObjectModel?
var managedObjectContext : NSManagedObjectContext?

init() {
override init() {
managedObjectModel = NSManagedObjectModel.mergedModelFromBundles(nil)

persistentStoreCoordinator = NSPersistentStoreCoordinator(managedObjectModel: managedObjectModel)
persistentStoreCoordinator = NSPersistentStoreCoordinator(managedObjectModel: managedObjectModel!)

let domains = NSSearchPathDomainMask.UserDomainMask
let directory = NSSearchPathDirectory.DocumentDirectory
Expand All @@ -46,21 +46,21 @@ class CoreDataStore : NSObject {
super.init()
}

func fetchEntriesWithPredicate(predicate: NSPredicate, sortDescriptors: AnyObject[], completionBlock: ((ManagedTodoItem[]) -> Void)!) {
func fetchEntriesWithPredicate(predicate: NSPredicate, sortDescriptors: [AnyObject], completionBlock: (([ManagedTodoItem]) -> Void)!) {
let fetchRequest = NSFetchRequest(entityName: "TodoItem")
fetchRequest.predicate = predicate
fetchRequest.sortDescriptors = []

managedObjectContext?.performBlock {
let queryResults = self.managedObjectContext?.executeFetchRequest(fetchRequest, error: nil)
let managedResults = queryResults! as ManagedTodoItem[]
let managedResults = queryResults! as! [ManagedTodoItem]
completionBlock(managedResults)
}
}

func newTodoItem() -> ManagedTodoItem {
let entityDescription = NSEntityDescription.entityForName("TodoItem", inManagedObjectContext: managedObjectContext)
let newEntry = NSManagedObject(entity: entityDescription, insertIntoManagedObjectContext: managedObjectContext) as ManagedTodoItem
let entityDescription = NSEntityDescription.entityForName("TodoItem", inManagedObjectContext: managedObjectContext!)
let newEntry = NSManagedObject(entity: entityDescription!, insertIntoManagedObjectContext: managedObjectContext) as! ManagedTodoItem

return newEntry
}
Expand Down
2 changes: 1 addition & 1 deletion VIPER-SWIFT/Classes/Common/View/RootWireframe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RootWireframe : NSObject {
}

func navigationControllerFromWindow(window: UIWindow) -> UINavigationController {
let navigationController = window.rootViewController as UINavigationController
let navigationController = window.rootViewController as! UINavigationController
return navigationController
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AddInteractor : NSObject {
var addDataManager : AddDataManager?

func saveNewEntryWithName(name: NSString, dueDate: NSDate) {
let newEntry = TodoItem(dueDate: dueDate, name: name)
let newEntry = TodoItem(dueDate: dueDate, name: name as String)
addDataManager?.addNewEntry(newEntry)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class AddDataManager : NSObject {
var dataStore : CoreDataStore?

func addNewEntry(entry: TodoItem) {
let newEntry = dataStore?.newTodoItem() as ManagedTodoItem
newEntry.name = entry.name
newEntry.date = entry.dueDate;
let newEntry = dataStore?.newTodoItem()
newEntry!.name = entry.name
newEntry!.date = entry.dueDate;

dataStore?.save()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import Foundation
import UIKit

class AddDismissalTransition : NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(transitionContext: UIViewControllerContextTransitioning!) -> NSTimeInterval {
func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval {
return 0.72
}

func animateTransition(transitionContext: UIViewControllerContextTransitioning!) {
let fromVC = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) as AddViewController
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
let fromVC = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) as! AddViewController

let finalCenter = CGPointMake(160.0, (fromVC.view.bounds.size.height / 2) - 1000.0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import Foundation
import UIKit

class AddPresentationTransition: NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(transitionContext: UIViewControllerContextTransitioning!) -> NSTimeInterval {
func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval {
return 0.72
}

func animateTransition(transitionContext: UIViewControllerContextTransitioning!) {
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
let fromVC = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)
let toVC = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) as AddViewController
let toVC = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) as! AddViewController

toVC.transitioningBackgroundView.backgroundColor = UIColor.darkGrayColor()
toVC.transitioningBackgroundView.alpha = 0.0
Expand All @@ -29,7 +29,7 @@ class AddPresentationTransition: NSObject, UIViewControllerAnimatedTransitioning
let toViewFrame = CGRectMake(0, 0, 260, 300)
toVC.view.frame = toViewFrame

let finalCenter = CGPointMake(fromVC.view.bounds.size.width / 2, 20 + toViewFrame.size.height / 2)
let finalCenter = CGPointMake(fromVC!.view.bounds.size.width / 2, 20 + toViewFrame.size.height / 2)
toVC.view.center = CGPointMake(finalCenter.x, finalCenter.y - 1000)

let options = UIViewAnimationOptions.CurveEaseIn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import UIKit
class AddViewController: UIViewController, UITextFieldDelegate, AddViewInterface {
var eventHandler : AddModuleInterface?

@IBOutlet var nameTextField : UITextField
@IBOutlet var nameTextField : UITextField!
@IBOutlet var datePicker : UIDatePicker?

var minimumDate : NSDate = NSDate()
Expand Down Expand Up @@ -53,7 +53,7 @@ class AddViewController: UIViewController, UITextFieldDelegate, AddViewInterface
}

func setEntryName(name: NSString) {
nameTextField.text = name
nameTextField.text = name as String
}

func setEntryDueDate(date: NSDate) {
Expand All @@ -70,7 +70,7 @@ class AddViewController: UIViewController, UITextFieldDelegate, AddViewInterface
}
}

func textFieldShouldReturn(textField: UITextField!) -> Bool {
func textFieldShouldReturn(textField: UITextField) -> Bool {
textField.resignFirstResponder()

return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AddWireframe : NSObject, UIViewControllerTransitioningDelegate {

func addViewController() -> AddViewController {
let storyboard = mainStoryboard()
let addViewController: AddViewController = storyboard.instantiateViewControllerWithIdentifier(AddViewControllerIdentifier) as AddViewController
let addViewController: AddViewController = storyboard.instantiateViewControllerWithIdentifier(AddViewControllerIdentifier) as! AddViewController
return addViewController
}

Expand All @@ -44,11 +44,11 @@ class AddWireframe : NSObject, UIViewControllerTransitioningDelegate {
return storyboard
}

func animationControllerForDismissedController(dismissed: UIViewController!) -> UIViewControllerAnimatedTransitioning! {
func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return AddDismissalTransition()
}

func animationControllerForPresentedController(presented: UIViewController!, presentingController presenting: UIViewController!, sourceController source: UIViewController!) -> UIViewControllerAnimatedTransitioning! {
func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return AddPresentationTransition()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class ListInteractor : NSObject, ListInteractorInput {
})
}

func upcomingItemsFromToDoItems(todoItems: TodoItem[]) -> UpcomingItem[] {
func upcomingItemsFromToDoItems(todoItems: [TodoItem]) -> [UpcomingItem] {
let calendar = NSCalendar.autoupdatingCurrentCalendar()

var upcomingItems : UpcomingItem[] = []
var upcomingItems : [UpcomingItem] = []

for todoItem in todoItems {
var dateRelation = calendar.nearTermRelationForDate(todoItem.dueDate, relativeToToday: clock.today())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ protocol ListInteractorInput {
}

protocol ListInteractorOutput {
func foundUpcomingItems(upcomingItems: UpcomingItem[])
func foundUpcomingItems(upcomingItems: [UpcomingItem])
}
Loading

0 comments on commit 19d4fcf

Please sign in to comment.