diff --git a/asphalos/AccountEditController.swift b/asphalos/AccountEditController.swift index b05386e..9facc67 100644 --- a/asphalos/AccountEditController.swift +++ b/asphalos/AccountEditController.swift @@ -99,9 +99,9 @@ class AccountEditController: FormViewController, FormViewControllerDelegate { category.accountCount = NSNumber(int: category.accountCount.integerValue + 1) } ///MARK: TODO Perhaps we can use property descriptors and then check validity on the object itself - account!.name = values[Fields.Name] as String - account!.userName = values[Fields.UserName] as String - account!.password = values[Fields.Password] as String + account!.name = values[Fields.Name] as! String + account!.userName = values[Fields.UserName] as! String + account!.password = values[Fields.Password] as! String account!.category = self.category //Non required values diff --git a/asphalos/AppDelegate.swift b/asphalos/AppDelegate.swift index e90ff71..a28add8 100644 --- a/asphalos/AppDelegate.swift +++ b/asphalos/AppDelegate.swift @@ -53,7 +53,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { lazy var applicationDocumentsDirectory: NSURL = { let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask) - return urls[urls.count-1] as NSURL + return urls[urls.count-1] as! NSURL }() lazy var managedObjectModel: NSManagedObjectModel = { @@ -79,7 +79,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data" dict[NSLocalizedFailureReasonErrorKey] = failureReason dict[NSUnderlyingErrorKey] = error - error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict) + error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict as [NSObject : AnyObject]) // Replace this with code to handle the error appropriately. // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. NSLog("Unresolved error \(error), \(error!.userInfo)") diff --git a/asphalos/CategoriesController.swift b/asphalos/CategoriesController.swift index 53cdc2c..a2e5840 100644 --- a/asphalos/CategoriesController.swift +++ b/asphalos/CategoriesController.swift @@ -43,7 +43,7 @@ class CategoriesController: UITableViewController, CategoryDelegate, SettingsDel ///MARK: Refresh methods func loadData(reload:Bool = false) { - self.categories = NSManagedObject.fetchAll("Category", sortKeys: [("name", true)]) as [Category] + self.categories = NSManagedObject.fetchAll("Category", sortKeys: [("name", true)]) as! [Category] if reload { self.tableView.reloadData() } @@ -76,7 +76,7 @@ class CategoriesController: UITableViewController, CategoryDelegate, SettingsDel func settings() { self.pushControllerOnNavigationStack("SettingsController", callback: { (controller:SettingsController) -> () in controller.settingsDelegate = self - }, transitionSyle: nil) + }) } // MARK: - Table view data source @@ -101,9 +101,9 @@ class CategoriesController: UITableViewController, CategoryDelegate, SettingsDel cell.textLabel?.text = accountResults[indexPath.row].name cell.detailTextLabel?.text = accountResults[indexPath.row].category.name } else { - cell = tableView.dequeueReusableCellWithIdentifier("CategoryCell", forIndexPath: indexPath) as UITableViewCell - (cell.contentView.viewWithTag(1) as UILabel).text = categories[indexPath.row].name - (cell.contentView.viewWithTag(2) as UILabel).text = "\(categories[indexPath.row].accountCount) accounts" + cell = tableView.dequeueReusableCellWithIdentifier("CategoryCell", forIndexPath: indexPath) as! UITableViewCell + (cell.contentView.viewWithTag(1) as! UILabel).text = categories[indexPath.row].name + (cell.contentView.viewWithTag(2) as! UILabel).text = "\(categories[indexPath.row].accountCount) accounts" } return cell } @@ -129,10 +129,10 @@ class CategoriesController: UITableViewController, CategoryDelegate, SettingsDel var editAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Edit") { (action, indexPath) -> Void in println("Edit") - self.pushControllerOnNavigationStack("CategoryEditController", callback: { (controller:CategoryEditController) -> () in + self.pushControllerOnNavigationStack("CategoryEditController", transitionSyle: nil, callback: { (controller:CategoryEditController) -> () in controller.category = self.categories[indexPath.row] controller.categoryDelegate = self - }, transitionSyle: nil) + }) } editAction.backgroundColor = UIColor.greenColor() @@ -146,12 +146,12 @@ class CategoriesController: UITableViewController, CategoryDelegate, SettingsDel //MARK: Private private func filter(q:String) { - self.accountResults = NSManagedObject.fetch("Account", predicates: { () -> NSPredicate in - return NSPredicate(format: "%K CONTAINS[cd] %@", "name", q)! - }, sortKeys: [("name", true)]) as [Account] + self.accountResults = (NSManagedObject.fetch("Account", sortKeys: [("name", true)], predicates: { () -> NSPredicate in + return NSPredicate(format: "%K CONTAINS[cd] %@", argumentArray: ["name", q]) + }) as? [Account])! } - func searchDisplayController(controller: UISearchDisplayController!, shouldReloadTableForSearchString searchString: String!) -> Bool { + func searchDisplayController(controller: UISearchDisplayController, shouldReloadTableForSearchString searchString: String!) -> Bool { self.filter(searchString) return true } diff --git a/asphalos/CategoryController.swift b/asphalos/CategoryController.swift index c4dd3f0..13d74e6 100644 --- a/asphalos/CategoryController.swift +++ b/asphalos/CategoryController.swift @@ -45,9 +45,9 @@ class CategoryController: UITableViewController, AccountDelegate { ///MARK: Refresh methods func loadData(reload:Bool = false) { - self.accounts = NSManagedObject.fetch("Account", predicates: { () -> NSPredicate in - return NSPredicate(format: "category = %@", self.category)! - }, sortKeys: [("name", true)]) as [Account] + self.accounts = NSManagedObject.fetch("Account", sortKeys: [("name", true)], predicates: { () -> NSPredicate in + return NSPredicate(format: "category = %@", argumentArray: [self.category]) + }) as! [Account] if reload { self.tableView.reloadData() } @@ -90,8 +90,8 @@ class CategoryController: UITableViewController, AccountDelegate { override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCellWithIdentifier("AccountCell", forIndexPath: indexPath) as UITableViewCell - (cell.contentView.viewWithTag(1) as UILabel).text = accounts[indexPath.row].name + let cell = tableView.dequeueReusableCellWithIdentifier("AccountCell", forIndexPath: indexPath) as! UITableViewCell + (cell.contentView.viewWithTag(1) as! UILabel).text = accounts[indexPath.row].name return cell } diff --git a/asphalos/CategoryEditController.swift b/asphalos/CategoryEditController.swift index e12a4ef..1e4c507 100644 --- a/asphalos/CategoryEditController.swift +++ b/asphalos/CategoryEditController.swift @@ -59,7 +59,7 @@ class CategoryEditController: FormViewController, FormViewControllerDelegate { if isNew { category = NSManagedObject.newEntity("Category") as Category } - category!.name = (values[Fields.Name] as String).stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet()) + category!.name = (values[Fields.Name] as! String).stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet()) Category.save() self.proxy(categoryDelegate, callback: { (object:CategoryDelegate) -> () in object.categoryUpdated(self.category!, isNew: isNew) diff --git a/asphalos/Crypto.swift b/asphalos/Crypto.swift index 5799969..f27943f 100644 --- a/asphalos/Crypto.swift +++ b/asphalos/Crypto.swift @@ -23,6 +23,6 @@ extension String { //2 digits of zero-padded hex output.appendFormat("%02x", byte) } - return output + return output as String } } \ No newline at end of file diff --git a/asphalos/DataManager.swift b/asphalos/DataManager.swift index 0b216bb..a120d83 100644 --- a/asphalos/DataManager.swift +++ b/asphalos/DataManager.swift @@ -14,12 +14,12 @@ extension NSManagedObject { ///Save all of the changes class func save() { - let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate + let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate appDelegate.saveContext() } class func managedObjectContext() -> NSManagedObjectContext? { - let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate + let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate if let managedObjContext = appDelegate.managedObjectContext { return managedObjContext } else { @@ -57,7 +57,7 @@ extension NSManagedObject { ///New entity class func newEntity(entityName:String) -> T { - return NSEntityDescription.insertNewObjectForEntityForName(entityName, inManagedObjectContext: self.managedObjectContext()!) as T + return NSEntityDescription.insertNewObjectForEntityForName(entityName, inManagedObjectContext: self.managedObjectContext()!) as! T } ///Prepare sort descriptors for list of tuples with key, ascending order @@ -83,7 +83,7 @@ extension NSManagedObject { } ///Return specific objects for the given predicate - class func fetch(entityName:String, predicates:() -> NSPredicate, sortKeys:[(String, Bool)]? = nil) -> [NSManagedObject] { + class func fetch(entityName:String, sortKeys:[(String, Bool)]? = nil, predicates:() -> NSPredicate) -> [NSManagedObject] { let fetchRequest = NSFetchRequest(entityName: entityName) fetchRequest.predicate = predicates() if let _sortKeys = sortKeys { diff --git a/asphalos/Extensions.swift b/asphalos/Extensions.swift index cf50140..24024c3 100644 --- a/asphalos/Extensions.swift +++ b/asphalos/Extensions.swift @@ -12,7 +12,7 @@ import UIKit extension UIWindow { ///Navigate to root controller for the given nib func navigateToRootController(nibName: String) { - var rootController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier(nibName) as UIViewController + var rootController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier(nibName) as! UIViewController UIView.transitionWithView(self, duration: 0.5, options: UIViewAnimationOptions.TransitionCurlDown, animations: { self.rootViewController = rootController }, completion: nil) @@ -226,19 +226,19 @@ extension UIViewController { ///Callers have the opportunity to work with the controller once its created by passing code block to callback ///@param: nibName: Pass the storyboard name for the controller ///@param: callback: Pass the code block. Ensure to provide the actual type of your controller - func pushControllerOnNavigationStack(nibName:String, callback:(controller:T) -> (), transitionSyle:UIViewAnimationTransition? = nil) -> T { + func pushControllerOnNavigationStack(nibName:String, transitionSyle:UIViewAnimationTransition? = nil, callback:(controller:T) -> ()) -> T { self.navigationItem.title = "" - var controller:T = self.storyboard?.instantiateViewControllerWithIdentifier(nibName)! as T + var controller:T = self.storyboard?.instantiateViewControllerWithIdentifier(nibName) as! T callback(controller: controller) var currentView = self.navigationController!.view if transitionSyle != nil { UIView.animateWithDuration(0.75, animations: { () -> Void in UIView.setAnimationCurve(UIViewAnimationCurve.EaseIn) - self.navigationController?.pushViewController(controller as UIViewController, animated: false) + self.navigationController?.pushViewController(controller as! UIViewController, animated: false) UIView.setAnimationTransition(transitionSyle!, forView: currentView, cache: false) }, completion: nil) } else { - self.navigationController?.pushViewController(controller as UIViewController, animated: true) + self.navigationController?.pushViewController(controller as! UIViewController, animated: true) } return controller } @@ -250,18 +250,18 @@ extension UIViewController { if transitionSyle != nil { UIView.animateWithDuration(0.75, animations: { () -> Void in UIView.setAnimationCurve(UIViewAnimationCurve.EaseIn) - self.navigationController?.pushViewController(controller as UIViewController, animated: false) + self.navigationController?.pushViewController(controller as! UIViewController, animated: false) UIView.setAnimationTransition(transitionSyle!, forView: currentView, cache: false) }, completion: nil) } else { - self.navigationController?.pushViewController(controller as UIViewController, animated: true) + self.navigationController?.pushViewController(controller as! UIViewController, animated: true) } } ///Present the controller as a root controller func presentAsRootController(nibName:String, transitionStyle:UIViewAnimationOptions) { - var controller = self.storyboard!.instantiateViewControllerWithIdentifier(nibName) as UIViewController - var appDelegate:AppDelegate = (UIApplication.sharedApplication().delegate as AppDelegate) + var controller = self.storyboard!.instantiateViewControllerWithIdentifier(nibName) as! UIViewController + var appDelegate:AppDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate) UIView.transitionWithView(appDelegate.window!, duration: 0.5, options: transitionStyle, animations: { () -> Void in appDelegate.window!.rootViewController = controller }, completion: nil) @@ -270,9 +270,9 @@ extension UIViewController { ///Present as Model func presentAsModalController(nibName:String, callback:(controller:T) -> ()) { - var controller:T = self.storyboard?.instantiateViewControllerWithIdentifier(nibName)! as T + var controller:T = self.storyboard?.instantiateViewControllerWithIdentifier(nibName)! as! T callback(controller: controller) - var presentingController = controller as UIViewController + var presentingController = controller as! UIViewController presentingController.modalPresentationStyle = UIModalPresentationStyle.CurrentContext self.presentViewController(presentingController, animated: true, completion: nil) } diff --git a/asphalos/FormBaseCell.swift b/asphalos/FormBaseCell.swift index 8b3a4cf..a26478f 100755 --- a/asphalos/FormBaseCell.swift +++ b/asphalos/FormBaseCell.swift @@ -120,7 +120,7 @@ class FormBaseCell: UITableViewCell { } for visualConstraint in visualConstraints { - let constraints = NSLayoutConstraint.constraintsWithVisualFormat(visualConstraint as String, options: NSLayoutFormatOptions(0), metrics: nil, views: views) + let constraints = NSLayoutConstraint.constraintsWithVisualFormat(visualConstraint as! String, options: NSLayoutFormatOptions(0), metrics: nil, views: views) for constraint in constraints { customConstraints.append(constraint) } diff --git a/asphalos/FormCheckCell.swift b/asphalos/FormCheckCell.swift index 4c48fa4..a2dcce8 100755 --- a/asphalos/FormCheckCell.swift +++ b/asphalos/FormCheckCell.swift @@ -27,7 +27,7 @@ class FormCheckCell: FormTitleCell { rowDescriptor.value = false } - accessoryType = (rowDescriptor.value as Bool) ? .Checkmark : .None + accessoryType = (rowDescriptor.value as! Bool) ? .Checkmark : .None } override class func formViewController(formViewController: FormViewController, didSelectRow selectedRow: FormBaseCell) { @@ -41,11 +41,11 @@ class FormCheckCell: FormTitleCell { private func check() { if rowDescriptor.value != nil { - rowDescriptor.value = !(rowDescriptor.value as Bool) + rowDescriptor.value = !(rowDescriptor.value as! Bool) } else { rowDescriptor.value = true } - accessoryType = (rowDescriptor.value as Bool) ? .Checkmark : .None + accessoryType = (rowDescriptor.value as! Bool) ? .Checkmark : .None } } diff --git a/asphalos/FormDescriptor.swift b/asphalos/FormDescriptor.swift index 4010040..9de007d 100755 --- a/asphalos/FormDescriptor.swift +++ b/asphalos/FormDescriptor.swift @@ -45,7 +45,7 @@ class FormDescriptor: NSObject { } } } - return formValues.copy() as NSDictionary + return formValues.copy() as! NSDictionary } func validateForm() -> FormRowDescriptor! { diff --git a/asphalos/FormOptionsSelectorController.swift b/asphalos/FormOptionsSelectorController.swift index 5117188..e1d30e0 100755 --- a/asphalos/FormOptionsSelectorController.swift +++ b/asphalos/FormOptionsSelectorController.swift @@ -15,11 +15,6 @@ class FormOptionsSelectorController: UITableViewController, FormSelector { var formCell: FormBaseCell! /// MARK: Init - - override init() { - super.init(style: .Grouped) - } - required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } @@ -59,7 +54,7 @@ class FormOptionsSelectorController: UITableViewController, FormSelector { cell = UITableViewCell(style: .Default, reuseIdentifier: reuseIdentifier) } - let optionValue = formCell.rowDescriptor.options[indexPath.row] as NSObject + let optionValue = formCell.rowDescriptor.options[indexPath.row] as! NSObject var uiLabel = cell!.textLabel! as UILabel uiLabel.text = formCell.rowDescriptor.titleForOptionValue(optionValue) @@ -95,7 +90,7 @@ class FormOptionsSelectorController: UITableViewController, FormSelector { let cell = tableView.cellForRowAtIndexPath(indexPath) let allowsMultipleSelection = formCell.rowDescriptor.allowsMultipleSelection - let optionValue = formCell.rowDescriptor.options[indexPath.row] as NSObject + let optionValue = formCell.rowDescriptor.options[indexPath.row] as! NSObject if allowsMultipleSelection { diff --git a/asphalos/FormReadTextFieldCell.swift b/asphalos/FormReadTextFieldCell.swift index 64339c8..608440f 100644 --- a/asphalos/FormReadTextFieldCell.swift +++ b/asphalos/FormReadTextFieldCell.swift @@ -68,7 +68,7 @@ class FormReadTextFieldCell: FormBaseCell { override func defaultVisualConstraints() -> [String] { let _imageView = self.imageView! as UIImageView if _imageView.image != nil { - if titleLabel.text != nil && countElements(titleLabel.text!) > 0 { + if titleLabel.text != nil && count(titleLabel.text!) > 0 { return ["H:[imageView]-[titleLabel]-[valueLabel]-16-|"] } else { @@ -76,7 +76,7 @@ class FormReadTextFieldCell: FormBaseCell { } } else { - if titleLabel.text != nil && countElements(titleLabel.text!) > 0 { + if titleLabel.text != nil && count(titleLabel.text!) > 0 { return ["H:|-16-[titleLabel]-[valueLabel]-16-|"] } else { diff --git a/asphalos/FormRowDescriptor.swift b/asphalos/FormRowDescriptor.swift index bae1895..3ba7105 100755 --- a/asphalos/FormRowDescriptor.swift +++ b/asphalos/FormRowDescriptor.swift @@ -95,7 +95,7 @@ class FormRowDescriptor: NSObject { /// MARK: Public interface func titleForOptionAtIndex(index: Int) -> String! { - return titleForOptionValue(options[index] as NSObject) + return titleForOptionValue(options[index] as! NSObject) } func titleForOptionValue(optionValue: NSObject) -> String! { @@ -103,7 +103,7 @@ class FormRowDescriptor: NSObject { return titleFormatter(optionValue) } else if optionValue is String { - return optionValue as String + return optionValue as! String } return "\(optionValue)" } diff --git a/asphalos/FormSegmentedControlCell.swift b/asphalos/FormSegmentedControlCell.swift index e7b94eb..492c259 100755 --- a/asphalos/FormSegmentedControlCell.swift +++ b/asphalos/FormSegmentedControlCell.swift @@ -52,7 +52,7 @@ class FormSegmentedControlCell: FormBaseCell { var idx = 0 if rowDescriptor.value != nil { for optionValue in rowDescriptor.options { - if optionValue as NSObject == rowDescriptor.value { + if optionValue as! NSObject == rowDescriptor.value { segmentedControl.selectedSegmentIndex = idx break } @@ -67,7 +67,7 @@ class FormSegmentedControlCell: FormBaseCell { override func defaultVisualConstraints() -> [String] { - if titleLabel.text != nil && countElements(titleLabel.text!) > 0 { + if titleLabel.text != nil && count(titleLabel.text!) > 0 { return ["H:|-16-[titleLabel]-16-[segmentedControl]-16-|"] } else { @@ -88,7 +88,7 @@ class FormSegmentedControlCell: FormBaseCell { segmentedControl.removeAllSegments() var idx = 0 for optionValue in rowDescriptor.options { - segmentedControl.insertSegmentWithTitle(rowDescriptor.titleForOptionValue(optionValue as NSObject), atIndex: idx, animated: false) + segmentedControl.insertSegmentWithTitle(rowDescriptor.titleForOptionValue(optionValue as! NSObject), atIndex: idx, animated: false) ++idx } } diff --git a/asphalos/FormSelectorCell.swift b/asphalos/FormSelectorCell.swift index 96f188f..cdb28bf 100755 --- a/asphalos/FormSelectorCell.swift +++ b/asphalos/FormSelectorCell.swift @@ -21,11 +21,11 @@ class FormSelectorCell: FormValueCell { if let selectedValues = rowDescriptor.value as? NSMutableArray { // multiple values - let indexedSelectedValues = NSSet(array: selectedValues) + let indexedSelectedValues = NSSet(array: selectedValues as [AnyObject]) for optionValue in rowDescriptor.options { if indexedSelectedValues.containsObject(optionValue) { - let optionTitle = rowDescriptor.titleForOptionValue(optionValue as NSObject) + let optionTitle = rowDescriptor.titleForOptionValue(optionValue as! NSObject) if title != nil { title = title + ", \(optionTitle)" } @@ -39,7 +39,7 @@ class FormSelectorCell: FormValueCell { title = rowDescriptor.titleForOptionValue(selectedValue) } - if title != nil && countElements(title) > 0 { + if title != nil && count(title) > 0 { valueLabel.text = title valueLabel.textColor = UIColor.blackColor() } diff --git a/asphalos/FormSwitchCell.swift b/asphalos/FormSwitchCell.swift index 2d4dd83..2c79cd9 100755 --- a/asphalos/FormSwitchCell.swift +++ b/asphalos/FormSwitchCell.swift @@ -31,7 +31,7 @@ class FormSwitchCell: FormTitleCell { titleLabel.text = rowDescriptor.title if rowDescriptor.value != nil { - switchView.on = rowDescriptor.value as Bool + switchView.on = rowDescriptor.value as! Bool } else { switchView.on = false diff --git a/asphalos/FormTextFieldCell.swift b/asphalos/FormTextFieldCell.swift index 1f70f89..fe5ee0f 100755 --- a/asphalos/FormTextFieldCell.swift +++ b/asphalos/FormTextFieldCell.swift @@ -119,7 +119,7 @@ class FormTextFieldCell: FormBaseCell { override func defaultVisualConstraints() -> [String] { let _imageView = self.imageView! as UIImageView if _imageView.image != nil { - if titleLabel.text != nil && countElements(titleLabel.text!) > 0 { + if titleLabel.text != nil && count(titleLabel.text!) > 0 { return ["H:[imageView]-[titleLabel]-[textField]-16-|"] } else { @@ -127,7 +127,7 @@ class FormTextFieldCell: FormBaseCell { } } else { - if titleLabel.text != nil && countElements(titleLabel.text!) > 0 { + if titleLabel.text != nil && count(titleLabel.text!) > 0 { return ["H:|-16-[titleLabel]-[textField]-16-|"] } else { @@ -148,6 +148,6 @@ class FormTextFieldCell: FormBaseCell { func editingChanged(sender: UITextField) { let trimmedText = sender.text.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()) - rowDescriptor.value = countElements(trimmedText) > 0 ? sender.text : nil + rowDescriptor.value = count(trimmedText) > 0 ? sender.text : nil } } diff --git a/asphalos/FormTextareaCell.swift b/asphalos/FormTextareaCell.swift index 9a58083..18c2186 100644 --- a/asphalos/FormTextareaCell.swift +++ b/asphalos/FormTextareaCell.swift @@ -59,7 +59,7 @@ class FormTextareaCell: FormBaseCell, UITextViewDelegate { func textViewDidChange(textView: UITextView) { let trimmedText = textView.text.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()) - rowDescriptor.value = countElements(trimmedText) > 0 ? textView.text : nil + rowDescriptor.value = count(trimmedText) > 0 ? textView.text : nil } diff --git a/asphalos/FormValueCell.swift b/asphalos/FormValueCell.swift index 30db78a..716fbcf 100755 --- a/asphalos/FormValueCell.swift +++ b/asphalos/FormValueCell.swift @@ -60,7 +60,7 @@ class FormValueCell: FormBaseCell { rightPadding = 16 } - if titleLabel.text != nil && countElements(titleLabel.text!) > 0 { + if titleLabel.text != nil && count(titleLabel.text!) > 0 { return ["H:|-16-[titleLabel]-[valueLabel]-\(rightPadding)-|"] } else { diff --git a/asphalos/FormViewController.swift b/asphalos/FormViewController.swift index 20a7372..49ca02d 100755 --- a/asphalos/FormViewController.swift +++ b/asphalos/FormViewController.swift @@ -29,10 +29,6 @@ class FormViewController : UITableViewController { /// MARK: Init - override convenience init() { - self.init(style: .Grouped) - } - convenience init(form: FormDescriptor) { self.init() self.form = form @@ -174,7 +170,7 @@ class FormViewController : UITableViewController { // apply cell custom design if let cellConfiguration = rowDescriptor.cellConfiguration { for (keyPath, value) in rowDescriptor.cellConfiguration { - cell?.setValue(value, forKeyPath: keyPath as String) + cell?.setValue(value, forKeyPath: keyPath as! String) } } diff --git a/asphalos/Globals.swift b/asphalos/Globals.swift index 3fa4f6f..4f40a15 100644 --- a/asphalos/Globals.swift +++ b/asphalos/Globals.swift @@ -63,7 +63,7 @@ class PasswordManager { if let _err = error { return (false, _err) } else { - var master = dictionary?.objectForKey("asphalos.master") as String + var master = dictionary?.objectForKey("asphalos.master") as! String return (master == password.sha1(), nil) } } @@ -79,7 +79,7 @@ class PasswordManager { randomString.appendFormat("%C", letters.characterAtIndex(Int(rand))) } - return randomString + return randomString as String } } diff --git a/asphalos/Main.storyboard b/asphalos/Main.storyboard index dd32128..2968f4d 100644 --- a/asphalos/Main.storyboard +++ b/asphalos/Main.storyboard @@ -1,7 +1,7 @@ - + - + @@ -110,7 +110,6 @@ - diff --git a/asphalos/MasterPasswordTextField.swift b/asphalos/MasterPasswordTextField.swift index 5b8b1d9..08c49c6 100644 --- a/asphalos/MasterPasswordTextField.swift +++ b/asphalos/MasterPasswordTextField.swift @@ -22,18 +22,13 @@ class MasterPasswordTextField: UITextField, UITextFieldDelegate { self.localInit() } - override init() { - super.init() - self.localInit() - } - private func localInit() { self.delegate = self self.secureTextEntry = true } func isValid() -> Bool{ - return !self.text.isEmpty && self.text.utf16Count > 10 + return !self.text.isEmpty && count(self.text.utf16) > 10 } } diff --git a/asphalos/SFSwiftNotification.swift b/asphalos/SFSwiftNotification.swift index 81f3d12..d8afe57 100644 --- a/asphalos/SFSwiftNotification.swift +++ b/asphalos/SFSwiftNotification.swift @@ -55,9 +55,11 @@ class SFSwiftNotification: UIView, UICollisionBehaviorDelegate, UIDynamicAnimato self.animationType = animationType self.direction = direction self.delegate = delegate - + label = UILabel(frame: CGRectMake(5, 0, frame.width - 5, frame.height)) - label.text = title + if let _title = title { + label.text = _title as String + } label.textAlignment = NSTextAlignment.Center label.preferredMaxLayoutWidth = self.frame.size.width self.setTranslatesAutoresizingMaskIntoConstraints(false) diff --git a/asphalos/SettingsController.swift b/asphalos/SettingsController.swift index 14baabf..52b4765 100644 --- a/asphalos/SettingsController.swift +++ b/asphalos/SettingsController.swift @@ -68,7 +68,7 @@ class SettingsController: FormViewController, FormViewControllerDelegate { if didSelectRowDescriptor.tag == Fields.ResetMaster { self.pushControllerOnNavigationStack("MasterPasswordController", callback: { (controller:MasterPasswordController) -> () in // - }, transitionSyle: nil) + }) } else if didSelectRowDescriptor.tag == Fields.PurgeAll { SweetAlert().showAlert("Are you sure?", subTitle: "You will lose all your data. It cannot be recovered", style: AlertStyle.Warning, buttonTitle: "Cancel", buttonColor: Globals.Theme.AppTintColor , otherButtonTitle: "Yes, I am sure", action: { (isOtherButton) -> Void in if isOtherButton == false { diff --git a/asphalos/SweetAlert.swift b/asphalos/SweetAlert.swift index c2e6e6a..7bef0cc 100644 --- a/asphalos/SweetAlert.swift +++ b/asphalos/SweetAlert.swift @@ -36,9 +36,9 @@ class SweetAlert: UIViewController { var userAction:((isOtherButton: Bool) -> Void)? = nil let kFont = Globals.Theme.RegularFont - override init() { - super.init() - + convenience init() { + self.init() + self.view.frame = UIScreen.mainScreen().bounds self.view.autoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth self.view.backgroundColor = UIColor(red:0, green:0, blue:0, alpha:kBakcgroundTansperancy) @@ -249,7 +249,7 @@ class SweetAlert: UIViewController { func showAlert(title: String, subTitle: String?, style: AlertStyle,buttonTitle: String,buttonColor: UIColor,otherButtonTitle: String?, otherButtonColor: UIColor?,action: ((isOtherButton: Bool) -> Void)? = nil) { userAction = action - let window = UIApplication.sharedApplication().keyWindow?.subviews.first as UIView + let window = UIApplication.sharedApplication().keyWindow?.subviews.first as! UIView window.addSubview(view) view.frame = window.bounds self.setupContentView() @@ -285,7 +285,7 @@ class SweetAlert: UIViewController { buttons = [] if buttonTitle.isEmpty == false { - var button: UIButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton + var button: UIButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton button.setTitle(buttonTitle, forState: UIControlState.Normal) button.backgroundColor = buttonColor button.userInteractionEnabled = true @@ -297,7 +297,7 @@ class SweetAlert: UIViewController { if otherButtonTitle != nil && otherButtonTitle!.isEmpty == false { - var button: UIButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton + var button: UIButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton button.setTitle(otherButtonTitle, forState: UIControlState.Normal) button.backgroundColor = otherButtonColor button.addTarget(self, action: "pressed:", forControlEvents: UIControlEvents.TouchUpInside) @@ -378,11 +378,7 @@ class CancelAnimatedView: AnimatableView { var circleLayer = CAShapeLayer() var crossPathLayer = CAShapeLayer() - - override init() { - super.init() - } - + override required init(frame: CGRect) { super.init(frame: frame) setupLayers() @@ -398,7 +394,7 @@ class CancelAnimatedView: AnimatableView { setupLayers() } - required override init(coder aDecoder: NSCoder) { + required init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -492,11 +488,7 @@ class InfoAnimatedView: AnimatableView { var circleLayer = CAShapeLayer() var crossPathLayer = CAShapeLayer() - - override init() { - super.init() - } - + override required init(frame: CGRect) { super.init(frame: frame) setupLayers() @@ -506,7 +498,7 @@ class InfoAnimatedView: AnimatableView { setupLayers() } - required override init(coder aDecoder: NSCoder) { + required init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -556,8 +548,8 @@ class SuccessAnimatedView: AnimatableView { var circleLayer = CAShapeLayer() var outlineLayer = CAShapeLayer() - override init() { - super.init() + convenience init() { + self.init() self.setupLayers() circleLayer.strokeStart = 0.0 circleLayer.strokeEnd = 0.0 @@ -571,7 +563,7 @@ class SuccessAnimatedView: AnimatableView { circleLayer.strokeEnd = 0.0 } - required override init(coder aDecoder: NSCoder) { + required init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/asphalos/TaskDetailController.swift b/asphalos/TaskDetailController.swift index 16fe74e..492f79f 100644 --- a/asphalos/TaskDetailController.swift +++ b/asphalos/TaskDetailController.swift @@ -53,12 +53,12 @@ class TaskDetailController: UITableViewController, TaskDelegate { override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { var cell:UITableViewCell! if indexPath.row == 0 { - cell = tableView.dequeueReusableCellWithIdentifier(TaskCell.Identifier, forIndexPath: indexPath) as UITableViewCell - (cell.contentView.viewWithTag(TaskCell.Task) as UILabel).text = task.name - (cell.contentView.viewWithTag(TaskCell.Length) as UILabel).text = task.lengthFormatted + cell = tableView.dequeueReusableCellWithIdentifier(TaskCell.Identifier, forIndexPath: indexPath) as! UITableViewCell + (cell.contentView.viewWithTag(TaskCell.Task) as! UILabel).text = task.name + (cell.contentView.viewWithTag(TaskCell.Length) as! UILabel).text = task.lengthFormatted } else { - cell = tableView.dequeueReusableCellWithIdentifier(TaskDetail.Identifier, forIndexPath: indexPath) as UITableViewCell - (cell.contentView.viewWithTag(TaskDetail.Detail) as UILabel).text = task.info + cell = tableView.dequeueReusableCellWithIdentifier(TaskDetail.Identifier, forIndexPath: indexPath) as! UITableViewCell + (cell.contentView.viewWithTag(TaskDetail.Detail) as! UILabel).text = task.info } return cell } @@ -80,7 +80,7 @@ class TaskDetailController: UITableViewController, TaskDelegate { controller.currentDate = self.currentDate controller.nextSlot = self.nextSlot controller.taskDelegate = self - }, transitionSyle: nil) + }) } func taskUpdated(task: Task, isNew: Bool) { diff --git a/asphalos/TaskEditController.swift b/asphalos/TaskEditController.swift index cf94567..85bee59 100644 --- a/asphalos/TaskEditController.swift +++ b/asphalos/TaskEditController.swift @@ -112,16 +112,16 @@ class TaskEditController: FormViewController, FormViewControllerDelegate { func save() { let values = self.form.formValues() - let length = (values.objectForKey("length") as String).toInt()! + let length = (values.objectForKey("length") as! String).toInt()! let isNew = self.isNew if isNew { self.task = NSManagedObject.newEntity("Task") as Task } - self.task.length = (values.objectForKey("length") as String).toInt()! + self.task.length = (values.objectForKey("length") as! String).toInt()! self.task.startDate = getTaskStartTime() - self.task.name = values.objectForKey(Fields.Task) as String - self.task.info = (values.objectForKey("info") as String) + self.task.name = values.objectForKey(Fields.Task) as! String + self.task.info = (values.objectForKey("info") as! String) self.task.completed = false self.task.actual = 0 self.task.order = nextSlot diff --git a/asphalos/TaskViewCell.swift b/asphalos/TaskViewCell.swift index 523405b..d32e5ed 100644 --- a/asphalos/TaskViewCell.swift +++ b/asphalos/TaskViewCell.swift @@ -83,7 +83,7 @@ class TaskViewCell: UITableViewCell /*SWTableViewCell*/ { var stringAttributes:NSDictionary = [NSFontAttributeName:self.textLabel!.font!] var size:CGSize = text.boundingRectWithSize(CGSizeMake(textLabelWidth, 20000.0), options: options, - attributes: stringAttributes, + attributes: stringAttributes as [NSObject : AnyObject], context: nil).size if (size.height < 21) { diff --git a/asphalos/TaskerController.swift b/asphalos/TaskerController.swift index a72b5bf..721cd4a 100644 --- a/asphalos/TaskerController.swift +++ b/asphalos/TaskerController.swift @@ -85,7 +85,7 @@ class TaskerController: UITableViewController, TaskDelegate, TaskMarked { func loadData(reload:Bool = false) { var predicate:NSPredicate! if toggleListOn { - predicate = NSPredicate(format: "completed = %@", false)! + predicate = NSPredicate(format: "completed = %@", false) } else { //Get day components from the current date and create range of one day var currentDayComponents = calendar.components(NSCalendarUnit.DayCalendarUnit | NSCalendarUnit.MonthCalendarUnit | NSCalendarUnit.YearCalendarUnit, fromDate: currentDate) @@ -95,12 +95,12 @@ class TaskerController: UITableViewController, TaskDelegate, TaskMarked { var dayComponent = NSDateComponents() dayComponent.day = 1 var endDate = self.calendar.dateByAddingComponents(dayComponent, toDate: startDate, options: NSCalendarOptions.allZeros)! - predicate = NSPredicate(format: "startDate >= %@ AND startDate <= %@ AND completed = %@", startDate, endDate, false)! + predicate = NSPredicate(format: "startDate >= %@ AND startDate <= %@ AND completed = %@", argumentArray: [startDate, endDate, false]) } - self.tasks = NSManagedObject.fetch("Task", predicates:{ () -> NSPredicate in + self.tasks = NSManagedObject.fetch("Task", sortKeys: [("startDate", true), ("order", true)], predicates:{ () -> NSPredicate in return predicate - }, sortKeys: [("startDate", true), ("order", true)]) as [Task] + }) as! [Task] if reload { self.tableView.reloadData() @@ -123,7 +123,7 @@ class TaskerController: UITableViewController, TaskDelegate, TaskMarked { } override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCellWithIdentifier("TaskViewCell", forIndexPath: indexPath) as TaskViewCell + let cell = tableView.dequeueReusableCellWithIdentifier("TaskViewCell", forIndexPath: indexPath) as! TaskViewCell self.updateCell(cell, task: tasks[indexPath.row], rowNum: indexPath.row) cell.taskMarkDelegate = self return cell @@ -164,7 +164,7 @@ class TaskerController: UITableViewController, TaskDelegate, TaskMarked { controller.currentDate = self.currentDate controller.nextSlot = self.nextSlot() controller.taskDelegate = self - }, transitionSyle: nil) + }) } override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool { @@ -178,7 +178,7 @@ class TaskerController: UITableViewController, TaskDelegate, TaskMarked { controller.taskDelegate = self controller.currentDate = self.currentDate controller.nextSlot = self.nextSlot() - }, transitionSyle: nil) + }) } func toggleList() { @@ -231,7 +231,7 @@ class TaskerController: UITableViewController, TaskDelegate, TaskMarked { if toggleListOn { return } - var longPress = sender as UILongPressGestureRecognizer + var longPress = sender as! UILongPressGestureRecognizer var state = longPress.state var location:CGPoint = longPress.locationInView(self.tableView) var indexPath = self.tableView.indexPathForRowAtPoint(location) @@ -270,8 +270,8 @@ class TaskerController: UITableViewController, TaskDelegate, TaskMarked { Task.SwapOrder(tasks[indexPath!.row], destination: tasks[sourceIndex!.row]) (tasks[indexPath!.row], tasks[sourceIndex!.row]) = (tasks[sourceIndex!.row], tasks[indexPath!.row]) self.tableView.moveRowAtIndexPath(sourceIndex!, toIndexPath: indexPath!) - self.updateCell(self.tableView.cellForRowAtIndexPath(sourceIndex!)! as TaskViewCell, task: tasks[sourceIndex!.row], rowNum: sourceIndex!.row) - self.updateCell(self.tableView.cellForRowAtIndexPath(indexPath!)! as TaskViewCell, task: tasks[indexPath!.row], rowNum: indexPath!.row) + self.updateCell(self.tableView.cellForRowAtIndexPath(sourceIndex!)! as! TaskViewCell, task: tasks[sourceIndex!.row], rowNum: sourceIndex!.row) + self.updateCell(self.tableView.cellForRowAtIndexPath(indexPath!)! as! TaskViewCell, task: tasks[indexPath!.row], rowNum: indexPath!.row) UIView.delay(0.5, callback: { () -> () in self.tableView.reloadSections(NSIndexSet(index: 0), withRowAnimation: UITableViewRowAnimation.Fade) }) @@ -315,7 +315,7 @@ class TaskerController: UITableViewController, TaskDelegate, TaskMarked { Task.save() if selected { self.tasks.removeAtIndex(rowNum) - let cell = self.tableView.cellForRowAtIndexPath(NSIndexPath(forRow: rowNum, inSection: 0)) as TaskViewCell + let cell = self.tableView.cellForRowAtIndexPath(NSIndexPath(forRow: rowNum, inSection: 0)) as! TaskViewCell self.tableView.deleteRowsAtIndexPaths([NSIndexPath(forRow: rowNum, inSection: 0)], withRowAnimation: UITableViewRowAnimation.Fade) UIView.delay(0.5, callback: { () -> () in self.tableView.reloadSections(NSIndexSet(index: 0), withRowAnimation: UITableViewRowAnimation.Fade)