Skip to content

Instantly share code, notes, and snippets.

View MTattin's full-sized avatar
:octocat:

Masakiyo Tachikawa MTattin

:octocat:
View GitHub Profile
@MTattin
MTattin / file0.swift
Created November 9, 2016 20:27
Swift3 動画をカメラロールに保存 ref: http://qiita.com/MTattin/items/ebb321adabe5282f0ebf
import UIKit
import AVFoundation
import Photos
///
/// アルバム保存コントローラーサンプル
///
class SaveAlbumSample: NSObject {
@MTattin
MTattin / file0.swift
Created October 17, 2016 11:13
UIVideoEditorControllerの「保存」のテキスト変更 ref: http://qiita.com/MTattin/items/a4563ce8e55dc0919c54
///
/// CstmVideoEditorController
///
class CstmVideoEditorController: UIVideoEditorController {
///
/// will appear
///
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
for v in self.navigationBar.subviews {
@MTattin
MTattin / file0.swift
Created October 10, 2016 01:51
swift3でのUIView.animateの挙動の違いについてのメモ ref: http://qiita.com/MTattin/items/3d541901db4b36e646d1
///
/// アニメーション表示
///
self.constraintBottom.constant = 0
UIView.animate(withDuration: 0.1, animations: { [weak self] in
self?.layoutIfNeeded()
}, completion: nil)
///
/// アニメーション非表示
@MTattin
MTattin / file0.swift
Created October 8, 2016 01:40
swift3の文字列操作(String.substring)メモ ref: http://qiita.com/MTattin/items/bf32562cd7d03c49026f
let Str: String = "123456789"
///
/// 先頭1文字 - 1
///
print("\(Str.substring(to: Str.index(after: Str.startIndex)))")
///
/// 先頭1文字以外 - 23456789
///
print("\(Str.substring(from: Str.index(after: Str.startIndex)))")
@MTattin
MTattin / file0.swift
Created August 1, 2016 12:07
UIPopoverPresentationControllerの画面回転対応メモ ref: http://qiita.com/MTattin/items/39f578610b295e9535b3
///
/// UIPopoverPresentationControllerDelegate
///
/// 画面の回転対応
///
func popoverPresentationController(_ popoverPresentationController: UIPopoverPresentationController, willRepositionPopoverTo rect: UnsafeMutablePointer<CGRect>, in view: AutoreleasingUnsafeMutablePointer<UIView>) {
let baseView = 起点としたいView
view.pointee = baseView
rect.pointee = baseView.bounds
@MTattin
MTattin / file0.txt
Created July 2, 2016 02:02
CFBundleVersionをReleaseビルドの時だけ更新 ref: http://qiita.com/MTattin/items/159e09e859f797429f9f
if [[ ${CONFIGURATION} == "Release" ]]; then
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PRODUCT_SETTINGS_PATH}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PRODUCT_SETTINGS_PATH}"
echo "[UpdateBuildNumber Release] CFBundleVersion Increment ${buildNumber}"
else
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PRODUCT_SETTINGS_PATH}")
echo "[UpdateBuildNumber Debug] CFBundleVersion Not Increment ${buildNumber}"
fi
let _0_delay = 3.0 * Double(NSEC_PER_SEC)
let _0_time = DispatchTime.now() + Double(Int64(_0_delay)) / Double(NSEC_PER_SEC)
DispatchQueue.main.acyncAfter(deadline: _0_time, execute: {
})
DispatchQueue.main.acyncAfter(deadline: DispatchTime.now() + Double(Int64(3.0 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: {
})
@MTattin
MTattin / file0.txt
Last active June 24, 2019 08:42
Firebase のプッシュ通知をcurlで実行 ref: https://qiita.com/MTattin/items/e6ebb18ec620ed89425e
curl \
--header "Authorization: key=ご自身のAPI_KEY" \
--header Content-Type:"application/json" \
https://fcm.googleapis.com/fcm/send \
-d "{
\"to\" : \"/topics/何か適当に\",
\"time_to_live\" : 0,
\"restricted_package_name\" : \"bundle id\",
\"notification\" : {
\"sound\" : \"default\",
/**
容量取得
- returns: freeとtotalのサイズ取得
*/
static func GetDiskSize() -> (free: Double?, total: Double?) {
let _0_paths: NSArray = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomainMask.UserDomainMask, true)
let _0_last: String = _0_paths.lastObject as! String
do {
let _0_dic: NSDictionary = try NSFileManager.defaultManager().attributesOfFileSystemForPath(_0_last)
return (
@MTattin
MTattin / file0.swift
Created March 6, 2016 12:46
swift2.0でのシェア方法の自分用メモ ref: http://qiita.com/MTattin/items/a911ef686144f5a84b0a
func share1() {
let shareText = "テキストテキスト\nテキストテキスト"
let shareWebsite = NSURL
let shareImage = UIImage
let activityItems = [
shareText,
shareWebsite,
shareImage,
]
let vc = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)