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
// ==UserScript== | |
// @name forgetyou | |
// @namespace forgetyou | |
// @include https://www.douban.com/* | |
// @version 1.1 | |
// @grant none | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js | |
// ==/UserScript== |
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
import Cocoa | |
protocol DragContainerDelegate { | |
func draggingEntered() | |
func draggingExit() | |
func draggingFileAccept(_ files: [URL]) | |
} | |
// https://stackoverflow.com/questions/29233247/implementing-a-drag-and-drop-zone-in-swift | |
class DragContainer: NSView { |
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
// 1. define Album Codalble | |
struct Album: Codable { | |
let title : String | |
let artist : String | |
let genre : String | |
let coverUrl : String | |
let year : String | |
} |
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
// 1. 在 Storyboard 中设置RestorationID | |
// 2. AppDelegate.swift中告诉App我们想要save和restore | |
func application(_ application: UIApplication, shouldSaveApplicationState coder: NSCoder) -> Bool { | |
return true | |
} | |
func application(_ application: UIApplication, shouldRestoreApplicationState coder: NSCoder) -> Bool { | |
return true | |
} |
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
// 📢名字:放在NSNotificationExtension.swift中,作为广播名字 | |
extension NSNotification.Name { | |
static let BLDownloadImage = Notification.Name("BLDownloadImageNotification") | |
} | |
// 📢发送:放在 AlbumView.swift中 | |
init(frame: CGRect, coverUrl: String) { | |
super.init(frame: frame) | |
commonInit() |
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
// | |
// HorizontalScrollerView.swift | |
// RWBlueLibrary | |
// | |
// Created by Xue Yu on 2/4/18. | |
// Copyright © 2018 Razeware LLC. All rights reserved. | |
// | |
import UIKit | |
// 把 DataSource 和 Delegate 协议分开,这样更优雅,并且可以减少不必要的 @objc 的使用 |
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
class Person: NSObject, Codable { | |
var firstName: String | |
var lastName: String | |
override var description: String { | |
return self.firstName + " " + self.lastName | |
} |
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
struct Person: Codable { | |
var firstName: String | |
var lastName: String | |
var name: Data? { | |
return try? PropertyListEncoder().encode(self) | |
} | |
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
class Person: NSObject, NSCoding { | |
var firstName: String | |
var lastName: String | |
override var description: String { | |
return self.firstName + " " + self.lastName | |
} | |