If you have to extend an existing object with additional property, always prefer Vue.set() over Object.assign() (or spread operator).
Example below explains implications for different implementations.
| let excludedActivityTypes = [ | |
| UIActivity.ActivityType.print, | |
| UIActivity.ActivityType.openInIBooks, | |
| UIActivity.ActivityType.copyToPasteboard, | |
| UIActivity.ActivityType.addToReadingList, | |
| UIActivity.ActivityType.assignToContact, | |
| UIActivity.ActivityType.copyToPasteboard, | |
| UIActivity.ActivityType.mail, | |
| UIActivity.ActivityType.markupAsPDF, | |
| UIActivity.ActivityType.postToFacebook, |
| // | |
| // AGUploadImageWebServices.swift | |
| // BaseProject | |
| // | |
| // Created by AshvinGudaliya on 27/02/18. | |
| // Copyright © 2018 AshvinGudaliya. All rights reserved. | |
| // | |
| import UIKit |
| let a: Double? = 1.0 | |
| let b: Double? = 2.0 | |
| let c: Double? = 3.0 | |
| let d: Double? = 4.0 | |
| let e: Double? = 5.0 | |
| let f: Double? = 6.0 | |
| let g: Double? = 7.0 | |
| extension Optional { | |
| func `or`(_ value : Wrapped?) -> Optional { |
| typealias Raw = [String: JSONDecodable & JSONEncodable] | |
| extension Dictionary: JSONDecodable { | |
| public init(jsonValue value: JSONValue) throws { | |
| guard let dictionary = forceBridgeFromObjectiveC(value) as? Dictionary else { | |
| throw JSONDecodingError.couldNotConvert(value: value, to: Dictionary.self) | |
| } | |
| self = dictionary | |
| } | |
| } |
| import Foundation | |
| import WebKit | |
| // See https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/AdoptingCocoaDesignPatterns.html for more details. | |
| private var observerContext = 0 | |
| class StackableWebView: WKWebView { | |
| // Keep track of height which will change when the view is loaded. | |
| var webViewHeight: CGFloat = 0.0 |
| Reasons to create UIs in code rather than Storyboards: | |
| Merge conflicts | |
| Easier to diff revisions and see changes in code | |
| More flexibility to move UI elements on iPad vs iPhone, | |
| portrait vs landscape | |
| Easier theme support |
| // check version | |
| node -v || node --version | |
| // list locally installed versions of node | |
| nvm ls | |
| // list remove available versions of node | |
| nvm ls-remote | |
| // install specific version of node |
| import WebKit | |
| class NativeWebViewController: UIViewController { | |
| let viewportScriptString = "var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); meta.setAttribute('initial-scale', '1.0'); meta.setAttribute('maximum-scale', '1.0'); meta.setAttribute('minimum-scale', '1.0'); meta.setAttribute('user-scalable', 'no'); document.getElementsByTagName('head')[0].appendChild(meta);" | |
| let disableSelectionScriptString = "document.documentElement.style.webkitUserSelect='none';" | |
| let disableCalloutScriptString = "document.documentElement.style.webkitTouchCallout='none';" | |
| override func viewDidLoad() { | |
| // 1 - Make user scripts for injection |
| //Usage | |
| lbl.attributedText = htmlToAttributedString ("html text") | |
| //Assign attributed string | |
| func htmlToAttributedString(string : String) -> NSAttributedString{ | |
| var attribStr = NSMutableAttributedString() | |
| do {//, allowLossyConversion: true | |
| attribStr = try NSMutableAttributedString(data: string.dataUsingEncoding(NSUnicodeStringEncoding)!, options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil) | |