Skip to content

Fixed warning "different optionality than expected by protocol 'NSFetchedResultsControllerDelegate" #35

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

Merged
merged 1 commit into from
Apr 15, 2015
Merged
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
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