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
let jsonString = """ | |
{ | |
"type":"fruit", | |
"size":{ | |
"width":150, | |
"height":150 | |
}, | |
"title":"Apple", | |
"url":"https:\\/\\/www.fruits.com\\/apple", | |
"isSample":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
let photoObject = Photo(title: "Hibiscus", url: URL(string: "https://www.flowers.com/hibiscus")!, isSample: false, metaData: ["color" : "red"], type: .flower, size: Size(width: 200, height: 200)) | |
let encodedData = try? JSONEncoder().encode(photoObject) |
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
struct Photo: Codable | |
{ | |
//String, URL, Bool and Date conform to Codable. | |
var title: String | |
var url: URL | |
var isSample: Bool | |
//The Dictionary is of type [String:String] and String already conforms to Codable. | |
var metaData: [String:String] | |
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, canEditRowAt indexPath: IndexPath) -> Bool | |
{ | |
return true | |
} | |
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? | |
{ | |
//An array of UITableViewRowAction objects representing the actions for the row. | |
} |
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
@available(iOS 11.0, *) | |
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? | |
{ | |
let deleteAction = UIContextualAction(style: .destructive, title: "Delete") { (action, view, handler) in | |
print("Delete Action Tapped") | |
} | |
deleteAction.backgroundColor = .red | |
let configuration = UISwipeActionsConfiguration(actions: [deleteAction]) | |
configuration.performsFirstActionWithFullSwipe = false //HERE.. | |
return configuration |
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, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? | |
{ | |
let deleteAction = UITableViewRowAction(style: .destructive, title: "Delete") { (action, indexpath) in | |
print("Delete Action Tapped") | |
} | |
deleteAction.backgroundColor = .red | |
return [deleteAction] | |
} |
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
@available(iOS 11.0, *) | |
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? | |
{ | |
let deleteAction = UIContextualAction(style: .destructive, title: "Add") { (action, view, handler) in | |
print("Add Action Tapped") | |
} | |
deleteAction.backgroundColor = .green | |
let configuration = UISwipeActionsConfiguration(actions: [deleteAction]) | |
return configuration | |
} |
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
let attributedString = NSAttributedString(string: "This is an attributed string.", | |
attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 10.0)]) |
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
class BaseCell: UITableViewCell | |
{ | |
func isBlank() -> Bool | |
{ | |
return false | |
} | |
func isValid() -> Bool | |
{ | |
return 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
override func viewDidLoad() | |
{ | |
super.viewDidLoad() | |
let button = UIButton(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) | |
button.addTarget(self, action: #selector(buttonClick), for: .touchUpInside) | |
} | |
@objc func buttonClick() //Add @objc in method definition | |
{ |