- Create a daemon configuration script under /etc/init ( NOT /etc/init.d ):-
nano /etc/init/mybot.conf
code sample:
description "MyBot Daemon"
author "alhazmy13"
start on startup
stop on shutdown
class MyButton: UIButton { | |
var action: (() -> ())? | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
sharedInit() | |
} | |
required init?(coder aDecoder: NSCoder) { |
// | |
// GradientView.swift | |
// Aura | |
// | |
// Created by Egor Sakhabaev on 23.07.17. | |
// Copyright © 2017 Egor Sakhabaev. All rights reserved. | |
// | |
import UIKit |
import Foundation | |
final class AnalyticsManager: AnalyticsService { | |
// MARK: - Properties - | |
// The list of services added to this class as observers. | |
internal private(set) var services = [AnalyticsService]() | |
// MARK: - Singleton - | |
static let instance = AnalyticsManager() |
let filePath = Bundle.main.pathForResource("YOUR_FILE_NAME", ofType: "json", inDirectory: nil) | |
if let filePath = filePath { | |
do { | |
let fileUrl = URL(fileURLWithPath: filePath) | |
let jsonData = try Data(contentsOf: fileUrl, options: .mappedIfSafe) | |
let json = try? JSONSerialization.jsonObject(with: jsonData) | |
} catch { | |
print(error) | |
fatalError("Unable to read contents of the file url") |
nano /etc/init/mybot.conf
code sample:
description "MyBot Daemon"
author "alhazmy13"
start on startup
stop on shutdown