This file contains 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
// Localization of numbers | |
import Foundation | |
let nf = NumberFormatter() | |
nf.numberStyle = .decimal | |
print(nf.string(from: 1234) ?? "INVALID NUMBER") | |
nf.locale = Locale(identifier: "es_ES") |
This file contains 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
var template = """ | |
<document> | |
<loadingTemplate> | |
<activityIndicator><text>Hello World!</text></activityIndicator> | |
</loadingTemplate> | |
</document> | |
""" | |
var templateParser = new DOMParser(); | |
var parsedTemplate = templateParser.parseFromString(template, "application/xml"); |
This file contains 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
# Note: Run in directory where javascript, e.g., applications.js, is stored | |
python -m SimpleHTTPServer 9001 |
This file contains 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
# Note: Run in directory where javascript, e.g., applications.js, is stored | |
ruby -run -ehttpd . -p9001 |
This file contains 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
<key>NSAppTransportSecurity</key> | |
<dict> | |
<key>NSAllowsArbitraryLoads</key> | |
<true/> | |
</dict> |
This file contains 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
// MARK: - Timeline Configuration | |
var startTime = Date() | |
func getSupportedTimeTravelDirections(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimeTravelDirections) -> Void) { | |
handler([.forward, .backward]) | |
} | |
func getTimelineStartDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -> Void) { | |
handler(startTime.addingTimeInterval(-(60.0 * 60.0 * 10))) |
This file contains 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
// TODO: import UserNotifications | |
// Create the notification content | |
let content = UNMutableNotificationContent() | |
content.title = "Hi" | |
content.body = "Hello" | |
print(#function, #line) | |
// Configure the notification trigger for 3 seconds |
This file contains 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
// Call the handler with the current timeline entry | |
let template = CLKComplicationTemplateModularSmallRingText() | |
template.textProvider = CLKSimpleTextProvider(text: "UA") | |
let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template) | |
handler(timelineEntry) |
This file contains 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 didSelectPost() { | |
// content of the post | |
print(#function, #line, self.contentText ?? "NO CONTENT") | |
// extract URL from attachments | |
if let item = extensionContext?.inputItems.first as? NSExtensionItem, | |
let itemProvider = item.attachments?.first as? NSItemProvider, | |
itemProvider.hasItemConformingToTypeIdentifier("public.url") { | |