Skip to content

Commit

Permalink
Merge pull request #35 from michaelarmstrong/fix/Warning
Browse files Browse the repository at this point in the history
Fixed warning "different optionality than expected by protocol 'NSFetchedResultsControllerDelegate"
  • Loading branch information
michaelarmstrong committed Apr 15, 2015
2 parents 39579a1 + cae412b commit bccf0d6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions SuperRecord/SuperFetchedResultsControllerDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class SuperFetchedResultsControllerDelegate : NSObject, NSFetchedResultsControll

// !MARK : Reusable View Updates (UICollectionView / UITableView)

func controllerWillChangeContent(controller: NSFetchedResultsController!)
func controllerWillChangeContent(controller: NSFetchedResultsController)
{
if(receiverType() == ReusableViewType.TableView){
tableView!.beginUpdates()
Expand All @@ -93,7 +93,7 @@ class SuperFetchedResultsControllerDelegate : NSObject, NSFetchedResultsControll
}
}

func controller(controller: NSFetchedResultsController!, didChangeSection sectionInfo: NSFetchedResultsSectionInfo!, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType)
func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType)
{
if(receiverType() == .TableView){
if type == NSFetchedResultsChangeType.Insert {
Expand All @@ -117,22 +117,23 @@ class SuperFetchedResultsControllerDelegate : NSObject, NSFetchedResultsControll
}
}

func controller(controller: NSFetchedResultsController!, didChangeObject anObject: AnyObject!, atIndexPath indexPath: NSIndexPath!, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath!)
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?)
{
if(receiverType() == ReusableViewType.TableView){
switch type {
case NSFetchedResultsChangeType.Insert:
tableView!.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: UITableViewRowAnimation.Fade)
tableView!.insertRowsAtIndexPaths([newIndexPath!], withRowAnimation: UITableViewRowAnimation.Fade)
case NSFetchedResultsChangeType.Delete:
tableView!.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Fade)
tableView!.deleteRowsAtIndexPaths([indexPath!], withRowAnimation: UITableViewRowAnimation.Fade)
case NSFetchedResultsChangeType.Update:
tableView!.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Fade)
tableView!.reloadRowsAtIndexPaths([indexPath!], withRowAnimation: UITableViewRowAnimation.Fade)
case NSFetchedResultsChangeType.Move:
tableView!.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Fade)
tableView!.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: UITableViewRowAnimation.Fade)
tableView!.deleteRowsAtIndexPaths([indexPath!], withRowAnimation: UITableViewRowAnimation.Fade)
tableView!.insertRowsAtIndexPaths([newIndexPath!], withRowAnimation: UITableViewRowAnimation.Fade)
default:
println("Unexpected NSFetchedResultsChangeType received for didChangeObject. \(type)")
}

} else if(receiverType() == ReusableViewType.CollectionView) {
var changeDictionary : Dictionary<NSFetchedResultsChangeType,AnyObject> = Dictionary()

Expand All @@ -148,7 +149,7 @@ class SuperFetchedResultsControllerDelegate : NSObject, NSFetchedResultsControll
break;
case NSFetchedResultsChangeType.Move:
// !TODO : we may need to migrate this to a homogenous Array as I expect this to throw a runtime exception.
changeDictionary[type] = [indexPath, newIndexPath]
changeDictionary[type] = [indexPath!, newIndexPath!]
break;
default:
println("Unexpected NSFetchedResultsChangeType received for didChangeObject. \(type)")
Expand All @@ -157,7 +158,7 @@ class SuperFetchedResultsControllerDelegate : NSObject, NSFetchedResultsControll
}
}

func controllerDidChangeContent(controller: NSFetchedResultsController!)
func controllerDidChangeContent(controller: NSFetchedResultsController)
{
if(receiverType() == ReusableViewType.TableView){
tableView!.endUpdates()
Expand Down

0 comments on commit bccf0d6

Please sign in to comment.