Skip to content

Instantly share code, notes, and snippets.

Payal Gupta pgpt10

  • Delhi
Block or report user

Report or block pgpt10

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View today_extension_7.swift
if isToHideWidget
{
NCWidgetController.widgetController().setHasContent(false, forWidgetWithBundleIdentifier: "YOUR_TODAY_EXTENSION_BUNDLE_IDENTIFIER")
}
else
{
NCWidgetController.widgetController().setHasContent(true, forWidgetWithBundleIdentifier: "YOUR_TODAY_EXTENSION_BUNDLE_IDENTIFIER")
}
View swift4_migration1.swift
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
{
View swift4_migration2.swift
class BaseCell: UITableViewCell
{
func isBlank() -> Bool
{
return false
}
func isValid() -> Bool
{
return false
View swift4_migration3.swift
let attributedString = NSAttributedString(string: "This is an attributed string.",
attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 10.0)])
View iOS11_TableView_Swipe_Actions1.swift
@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
}
View iOS11_TableView_Swipe_Actions2.swift
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]
}
View iOS11_TableView_Swipe_Actions3.swift
@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
View iOS11_TableView_Swipe_Actions4.swift
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.
}
View Codable1.swift
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]
View Codable2.swift
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)
You can’t perform that action at this time.