Skip to content

Instantly share code, notes, and snippets.

View Enriquecm's full-sized avatar

Enrique Choynowski Melgarejo Enriquecm

  • New Zealand
  • 01:02 (UTC +12:00)
View GitHub Profile
@Enriquecm
Enriquecm / PreviewController+LocalFile.swift
Last active November 11, 2024 07:46
Using QLPreviewController and SwiftUI to preview many common file types (PDF, iWork, Microsoft Office documents, images, texts, etc).
import SwiftUI
struct DocView: View {
@State private var buttonPressed: Bool = false
var body: some View {
Button {
buttonPressed = true
} label: {
Text("Show PDF file")
@Enriquecm
Enriquecm / Promise.swift
Created October 25, 2021 15:31
Simplest way to use promises
import Foundation
class Promise<Value> {
enum State<T> {
case completed(T)
case pending
}
@Enriquecm
Enriquecm / PDFViewController.swift
Created September 10, 2020 19:16
Handle links and gestures on PDFView
class PDFViewController: UIViewController {
@IBOutlet weak var viewPdf: PDFView!
override func viewDidLoad() {
super.viewDidLoad()
setupPDF()
}
/* If you need to use **different decoders (JSON, URL, XML, etc)** with Alamofire,
the best and simplest way I found was using [XMLCoder][1].
- **Alamofire 5**
- **Swift 5**
-------------------
*/
[1]: https://github.com/MaxDesiatov/XMLCoder
@Enriquecm
Enriquecm / CustomUITableviewSelection.swift
Last active July 24, 2020 10:34
UITableView selection programmatically
// MARK: UITableViewCell class
class TableViewCell: UITableViewCell {
override var isSelected: Bool {
didSet {
// Configure cell selection
}
}
}
@Enriquecm
Enriquecm / Create, Share and Install iOS Certificates.md
Last active May 11, 2017 19:15
The process to share a iOS Certificates.

Create

  1. Open Certificate area on https://developer.apple.com/account/ios/certificate/;
  2. Add a new iOS "Certificate";
  3. Select "AppStore and Ad Hoc" or "In-House and Ad Hoc" under Distribution;
  4. Follow the steps to create a CSR file
    • Open “Keychain Access” from your Applications > Utilities folder on your Mac;
    • Select Keychain Access > Certificate Assistant > Request a Certificate from a Certificate Authority;
    • In the User Email Address field, enter your email address;
    • In the Common Name field, create a name for your private key (e.g., John Doe Dev Key);
  • The CA Email Address field should be left empty.