A small menubar app that allows you to switch between R versions quickly (if you have multiple versions of R framework installed).
https://rud.is/rswitch
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
974 B
44 lines
974 B
//
|
|
// RStudioServerSessionManager.swift
|
|
// RSwitch
|
|
//
|
|
// Created by hrbrmstr on 9/5/19.
|
|
// Copyright © 2019 Bob Rudis. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import Cocoa
|
|
import WebKit
|
|
|
|
class RStudioServerSessionManager {
|
|
|
|
var sessions : [ RStudioServerSession ]?
|
|
|
|
init() {
|
|
loadSessions()
|
|
}
|
|
|
|
func newSession(url: String, title: String) {
|
|
sessions!.append(RStudioServerSession(url: url, title: title))
|
|
let sessionsData = try! JSONEncoder().encode(sessions)
|
|
UserDefaults.standard.set(sessionsData, forKey: "rstudioServerSessions")
|
|
}
|
|
|
|
func loadSessions() {
|
|
let sessionsData = UserDefaults.standard.data(forKey: "rstudioServerSessions")
|
|
if (sessionsData != nil) {
|
|
sessions = try! JSONDecoder().decode([RStudioServerSession].self, from: sessionsData!)
|
|
} else {
|
|
sessions = [ RStudioServerSession ]()
|
|
}
|
|
}
|
|
|
|
func debugSessions() {
|
|
|
|
for s in sessions! {
|
|
print(s.menuTitle)
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|