Skip to content

Instantly share code, notes, and snippets.

@nazrdogan
Created March 5, 2019 09:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nazrdogan/c142e4eb94823d51cde16dad2cbb60a8 to your computer and use it in GitHub Desktop.
Save nazrdogan/c142e4eb94823d51cde16dad2cbb60a8 to your computer and use it in GitHub Desktop.
//
// ComNextchapterOrangeModule.swift
// orange
//
// Created by Your Name
// Copyright (c) 2019 Your Company. All rights reserved.
//
import UIKit
import TitaniumKit
import OrangeTrustBadge
/**
Titanium Swift Module Requirements
---
1. Use the @objc annotation to expose your class to Objective-C (used by the Titanium core)
2. Use the @objc annotation to expose your method to Objective-C as well.
3. Method arguments always have the "[Any]" type, specifying a various number of arguments.
Unwrap them like you would do in Swift, e.g. "guard let arguments = arguments, let message = arguments.first"
4. You can use any public Titanium API like before, e.g. TiUtils. Remember the type safety of Swift, like Int vs Int32
and NSString vs. String.
*/
@objc(ComNextchapterOrangeModule)
class ComNextchapterOrangeModule: TiModule {
public let testProperty: String = "Hello World"
func moduleGUID() -> String {
return "34d56fd4-0a90-47ed-8a6b-908b4b07bcb9"
}
override func moduleId() -> String! {
return "com.nextchapter.orange"
}
override func startup() {
super.startup()
debugPrint("[DEBUG] \(self) loaded")
}
@objc(example:)
func example(arguments: Array<Any>?) {
let storyboard = UIStoryboard(name: "OrangeTrustBadge", bundle: Bundle(for: TrustBadge.self))
if let viewController = storyboard.instantiateInitialViewController() {
TiApp.controller()?.topContainerController()?.present(viewController, animated: true)
}
}
@objc public var exampleProp: String {
get {
// Example property getter
return "Titanium rocks!"
}
set {
// Example property setter
// Call with "MyModule.exampleProp = 'newValue'"
self.replaceValue(newValue, forKey: "exampleProp", notification: false)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment