Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift updates. Xcode 6 GM. #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
110 changes: 110 additions & 0 deletions VIPER-SWIFT.xcodeproj/xcshareddata/xcschemes/VIPER-SWIFT.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "261FA14D1941497E0029F589"
BuildableName = "VIPER-SWIFT.app"
BlueprintName = "VIPER-SWIFT"
ReferencedContainer = "container:VIPER-SWIFT.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "261FA15F1941497E0029F589"
BuildableName = "VIPER-SWIFTTests.xctest"
BlueprintName = "VIPER-SWIFTTests"
ReferencedContainer = "container:VIPER-SWIFT.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "261FA15F1941497E0029F589"
BuildableName = "VIPER-SWIFTTests.xctest"
BlueprintName = "VIPER-SWIFTTests"
ReferencedContainer = "container:VIPER-SWIFT.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "261FA14D1941497E0029F589"
BuildableName = "VIPER-SWIFT.app"
BlueprintName = "VIPER-SWIFT"
ReferencedContainer = "container:VIPER-SWIFT.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "261FA14D1941497E0029F589"
BuildableName = "VIPER-SWIFT.app"
BlueprintName = "VIPER-SWIFT"
ReferencedContainer = "container:VIPER-SWIFT.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "261FA14D1941497E0029F589"
BuildableName = "VIPER-SWIFT.app"
BlueprintName = "VIPER-SWIFT"
ReferencedContainer = "container:VIPER-SWIFT.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,35 @@ 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 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 {
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(NSCalendarUnit.WeekOfYearCalendarUnit, fromDate: date)
let duringSameWeekComponents = components(NSCalendarUnit.WeekOfYearCalendarUnit, fromDate: duringSameWeekAsDate)
let result = dateComponents.weekOfYear == duringSameWeekComponents.weekOfYear
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(NSCalendarUnit.WeekOfYearCalendarUnit, fromDate: date)
let nextWeekComponents = components(NSCalendarUnit.WeekOfYearCalendarUnit, fromDate: nextWeek)
let result = dateComponents.weekOfYear == nextWeekComponents.weekOfYear
return result
}

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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AddDataManager : NSObject {
var dataStore : CoreDataStore?

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +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!) {

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,11 +10,11 @@ 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

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,18 +12,18 @@ 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()
var transitioningBackgroundView : UIView = UIView()

@IBAction func save(sender: AnyObject) {
eventHandler?.saveAddActionWithName(nameTextField.text, dueDate: datePicker!.date)
eventHandler?.saveAddActionWithName(nameTextField!.text, dueDate: datePicker!.date)
}

@IBAction func cancel(sender: AnyObject) {
nameTextField.resignFirstResponder()
nameTextField!.resignFirstResponder()
eventHandler?.cancelAddAction()
}

Expand All @@ -35,7 +35,7 @@ class AddViewController: UIViewController, UITextFieldDelegate, AddViewInterface

transitioningBackgroundView.userInteractionEnabled = true

nameTextField.becomeFirstResponder()
nameTextField!.becomeFirstResponder()

if let realDatePicker = datePicker {
realDatePicker.minimumDate = minimumDate
Expand All @@ -45,15 +45,15 @@ class AddViewController: UIViewController, UITextFieldDelegate, AddViewInterface
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)

nameTextField.resignFirstResponder()
nameTextField!.resignFirstResponder()
}

func dismiss() {
eventHandler?.cancelAddAction()
}

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

func setEntryDueDate(date: NSDate) {
Expand Down
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])
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Foundation
class ListDataManager : NSObject {
var coreDataStore : CoreDataStore?

func todoItemsBetweenStartDate(startDate: NSDate, endDate: NSDate, completion: ((TodoItem[]) -> Void)!) {
func todoItemsBetweenStartDate(startDate: NSDate, endDate: NSDate, completion: (([TodoItem]) -> Void)!) {
let calendar = NSCalendar.autoupdatingCurrentCalendar()
let beginning = calendar.dateForBeginningOfDay(startDate)
let end = calendar.dateForEndOfDay(endDate)
Expand All @@ -28,8 +28,8 @@ class ListDataManager : NSObject {
})
}

func todoItemsFromDataStoreEntries(entries: ManagedTodoItem[]) -> TodoItem[] {
var todoItems : TodoItem[] = []
func todoItemsFromDataStoreEntries(entries: [ManagedTodoItem]) -> [TodoItem] {
var todoItems : [TodoItem] = []

for managedTodoItem in entries {
let todoItem = TodoItem(dueDate: managedTodoItem.date, name: managedTodoItem.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ class ListPresenter : NSObject, ListInteractorOutput, ListModuleInterface, AddMo
listInteractor?.findUpcomingItems()
}

func foundUpcomingItems(upcomingItems: UpcomingItem[]) {
func foundUpcomingItems(upcomingItems: [UpcomingItem]) {
if upcomingItems.count == 0 {
userInterface?.showNoContentMessage()
} else {
updateUserInterfaceWithUpcomingItems(upcomingItems)
}
}

func updateUserInterfaceWithUpcomingItems(upcomingItems: UpcomingItem[]) {
func updateUserInterfaceWithUpcomingItems(upcomingItems: [UpcomingItem]) {
let upcomingDisplayData = upcomingDisplayDataWithItems(upcomingItems)
userInterface?.showUpcomingDisplayData(upcomingDisplayData)
}

func upcomingDisplayDataWithItems(upcomingItems: UpcomingItem[]) -> UpcomingDisplayData {
func upcomingDisplayDataWithItems(upcomingItems: [UpcomingItem]) -> UpcomingDisplayData {
let collection = UpcomingDisplayDataCollection()
collection.addUpcomingItems(upcomingItems)
return collection.collectedDisplayData()
Expand Down
Loading