View .gitignore
# Xcode | |
*/build/* | |
build/ | |
profile | |
*.moved-aside | |
DerivedData | |
.idea/ | |
*.hmap | |
*.xcuserstate | |
*.xccheckout |
View LFTableController
override func viewDidLoad() { | |
super.viewDidLoad() | |
lf_actionReload() | |
} | |
override func lf_actionReload() { | |
var array: Array<LTDictStrObj> = [ [ | |
"title": "Title 1", | |
"desc": "Description", | |
], [ |
View MBProgress+PFObject
let obj = PFObject(className: "sg_text") | |
obj.setObject(text_view!.text, forKey: SG.const.text) | |
MBProgressHUD.show("Analyzing...", view:view) | |
obj.saveInBackgroundWithBlock({ | |
(success: Bool?, error: NSError?) in | |
MBProgressHUD.hideAllHUDsForView(self.view, animated:true) | |
if error == nil { | |
LF.log("TEXT saved", obj) | |
} else { | |
MBProgressHUD.show(error!.localizedDescription, view:self.view, duration:2) |
View LFTableController+SearchDisplayController
class ICSearchController: LFTableController { | |
var source_search: LFTableDataSource! | |
//@IBOutlet var search_controller: UISearchDisplayController! | |
//@IBOutlet var search_bar: UISearchBar! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
reload_featured() | |
reload_search() |
View Swift Mail Composer
@IBAction func action_report() { | |
let composer = SVMailComposer() | |
composer.present(self, subject:SV.s.report_user_title, body:SV.s.report_user_body) | |
} | |
class SVMailComposer: MFMailComposeViewController, MFMailComposeViewControllerDelegate { | |
func present(controller: UIViewController, subject: String, body: String) { | |
if MFMailComposeViewController.canSendMail() { | |
mailComposeDelegate = self | |
setToRecipients(["leo@superarts.org"]) |
View ambiguous-logger.swift
/// TODO: is something like Loggable.Console / Loggable.File possible in Swift - single namespace inside a target? | |
// A console logger | |
protocol ConsoleLoggable { | |
var clogger: ConsoleLoggerProtocol { get } | |
} | |
extension ConsoleLoggable { | |
var clogger: ConsoleLoggerProtocol { |
View extension-computed-property.swift
// To maintain state of extension computed property, use static variable | |
// A console logger | |
protocol ConsoleLoggable { | |
var logger: ConsoleLoggerProtocol { get } | |
} | |
extension ConsoleLoggable { | |
var logger: ConsoleLoggerProtocol { |
View test-target.swift
protocol ProductionFeatureProtocol: TestFeature1, TestFeature2 { | |
} | |
struct DefaultProductionFeature: ProductionFeatureProtocol { | |
} | |
protocol TestFeature1 { | |
func testOnly1() |
View struct-in-static-func
struct TestStruct { | |
static var staticVar = 1 | |
static func staticFunc() { | |
staticVar = 2 | |
} | |
} |
View pure-func-in-enum
protocol PureEnumProtocol { | |
func test() | |
} | |
enum PureEnum: PureEnumProtocol { | |
static var v = 1 // Still possible | |
//var v = 1 // Enums must not contain stored properties | |
func test() { | |
//v = 2 // Impossible |
OlderNewer