Skip to content

Instantly share code, notes, and snippets.

@matsuhisa
matsuhisa / file0.swift
Last active August 29, 2015 14:10
モーダルのSegue.identifier でエラーが出る時の対処策 ref: http://qiita.com/matsuhisa@github/items/436110c24db0f754c3c4
if segue.identifier == "ShowDetail” {
// 処理
}
@matsuhisa
matsuhisa / file0.swift
Created November 29, 2014 07:11
Swiftで文字列からNSDateに変換する ref: http://qiita.com/matsuhisa@github/items/954ae6e921b5c48a5814
var date_string: String = "2014-12-01 10:00:00"
var date_formatter: NSDateFormatter = NSDateFormatter()
date_formatter.locale = NSLocale(localeIdentifier: "ja")
date_formatter.dateFormat = "yyyy/MM/dd HH:mm:ss"
date_formatter.dateFromString(date_string)
@matsuhisa
matsuhisa / UIPlaceHolderTextView.swift
Last active August 29, 2015 14:12
UITextViewでのPlaceHolder(プレースホルダ)をSwiftで実装する方法 ref: http://qiita.com/matsuhisa@github/items/5f4877e8ec89729de824
import UIKit
public class UIPlaceHolderTextView: UITextView {
lazy var placeHolderLabel:UILabel = UILabel()
var placeHolderColor:UIColor = UIColor.lightGrayColor()
var placeHolder:NSString = ""
required public init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
@matsuhisa
matsuhisa / file0.txt
Last active August 29, 2015 14:13
AWS(EC2:AMI)でcron実行時にメールを送信する方法 ref: http://qiita.com/matsuhisa@github/items/d2b8060b7b812d0909e8
echo body | mail -s "subject" -r 'from@example.com' 'to@example.com'
@matsuhisa
matsuhisa / SecondView.swift
Last active August 29, 2015 14:13
モーダルウィンドウをStoryboardで設定して、Delegateで値の受け渡しをする ref: http://qiita.com/matsuhisa@github/items/809c36fb766fb1049d4a
import UIKit
class SecondViewController: UIViewController {
@IBOutlet weak var BackButton: UIButton!
@IBOutlet weak var ToThirdViewBbutton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
@matsuhisa
matsuhisa / file0.swift
Last active August 29, 2015 14:14
SwiftでNSDateから文字列に変換(曜日あり)する ref: http://qiita.com/matsuhisa@github/items/7c898c0c2d0c523d4c0a
import UIKit
// 文字列 から NSDate
var date_string: String = "1996-3-15 10:11:00"
var date_formatter: NSDateFormatter = NSDateFormatter()
date_formatter.locale = NSLocale(localeIdentifier: "ja")
date_formatter.dateFormat = "yyyy/MM/dd HH:mm:ss"
var change_date:NSDate = date_formatter.dateFromString(date_string)!
@matsuhisa
matsuhisa / file0.swift
Created February 11, 2015 08:53
Swiftで UITextField から UIDatePicker を呼び出して Toolbarに完了ボタンなどを用意する ref: http://qiita.com/matsuhisa@github/items/4bb9803828efb89e0305
import UIKit
class ViewController: UIViewController, UIToolbarDelegate {
@IBOutlet weak var textField: UITextField!
//var textField: UITextField!
var toolBar:UIToolbar!
var myDatePicker: UIDatePicker!
override func viewDidLoad() {
@matsuhisa
matsuhisa / AppDelegate.swift
Last active August 29, 2015 14:15
Xcode6(Swift)で1つのプロジェクトから開発版とリリース版の2つのアプリを作りたい ref: http://qiita.com/matsuhisa@github/items/3f4e1ba0f05a69076dde
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
let splitViewController = self.window!.rootViewController as ViewController
@matsuhisa
matsuhisa / file0.swift
Last active August 29, 2015 14:16
SwiftでNSMutableArrayに追加したObjectをNSSortDescriptor使ってソートする ref: http://qiita.com/matsuhisa@github/items/fd8df5df7160b81a9e78
import UIKit
class Memo:NSObject {
var title = "無題"
var created_at = NSDate()
init(title:String) {
self.title = title
}
}
@matsuhisa
matsuhisa / file0.swift
Created April 12, 2015 14:48
Swift で UIActivityViewController を利用してfacebookやTwitterにシェアをする ref: http://qiita.com/matsuhisa@github/items/7a599e0276cfabe1090e
ButtonShare.addTarget(self, action: "share_action:", forControlEvents: .TouchUpInside)