This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NSManagedObject+CDAdditions.h | |
@interface NSManagedObject (CDAdditions) | |
+ (NSString *)CDAdditionsEntityName; | |
+ (instancetype)CDAdditionsInsertNewObjectIntoContext:(NSManagedObjectContext *)context; | |
@end | |
// NSManagedObject+CDAdditions.m | |
@implementation NSManagedObject (CDAdditions) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CDBaseManagedObject.h | |
@interface CDBaseManagedObject : NSManagedObject | |
+ (NSString *)entityName; | |
+ (instancetype)insertNewObjectIntoContext:(NSManagedObjectContext *)context; | |
@end | |
// CDBaseManagedObject.m | |
@implementation CDBaseManagedObject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { | |
@IBOutlet var tableView: UITableView! | |
private var swipeGestureStarted: Bool = false | |
private var selectedIndexPath: NSIndexPath? | |
override func viewDidLoad() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { | |
@IBOutlet var tableView: UITableView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "MyCellIdentifier") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { | |
return true | |
} | |
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { | |
if(editingStyle == UITableViewCellEditingStyle.Delete) { | |
// Here you should commit your editing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(tableView: UITableView, willBeginEditingRowAtIndexPath indexPath: NSIndexPath) { | |
self.swipeGestureStarted = true; | |
} | |
func tableView(tableView: UITableView, didEndEditingRowAtIndexPath indexPath: NSIndexPath) { | |
if(self.swipeGestureStarted) { | |
self.swipeGestureStarted = false | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { | |
@IBOutlet var tableView: UITableView! | |
private var swipeGestureStarted: Bool = false | |
private var selectedIndexPath: NSIndexPath? | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { | |
self.selectedIndexPath = indexPath | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(tableView: UITableView, willBeginEditingRowAtIndexPath indexPath: NSIndexPath) { | |
self.swipeGestureStarted = true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(tableView: UITableView, didEndEditingRowAtIndexPath indexPath: NSIndexPath) { | |
if(self.swipeGestureStarted) { | |
self.swipeGestureStarted = false | |
self.tableView.selectRowAtIndexPath(self.selectedIndexPath, animated: true, scrollPosition: .None) | |
} | |
} |
OlderNewer