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 UIKit | |
// コピーメニューが表示されるUIButton | |
class UIButtonWithCopyMenu: UIButton { | |
override func awakeFromNib() { | |
// 長押し処理を追加 | |
self.addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(UIButtonWithCopyMenu.showContextMenu(_:)))) | |
} |
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
github "ReactiveX/RxSwift" | |
github "realm/realm-cocoa" | |
github "Alamofire/Alamofire" ~> 4.4 | |
github "Alamofire/AlamofireImage" ~> 3.1 | |
github "Hearst-DD/ObjectMapper" ~> 2.2 | |
github "tristanhimmelman/AlamofireObjectMapper" ~> 4.0 |
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 Archiver: NSObject { | |
// 指定のデータをアーカイブします。 | |
static func encrypt(rootObject: Any) -> Data { | |
return NSKeyedArchiver.archivedData(withRootObject: rootObject) | |
} | |
// アーカイブデータを解凍して返します。 | |
static func decrypt<T>(data:Data) -> T? { | |
return NSKeyedUnarchiver.unarchiveObject(with: data) as? T | |
} |
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 UIKit | |
import Alamofire | |
import RxSwift | |
import ObjectMapper | |
import AlamofireObjectMapper | |
// Routerを実装してAPIを作成ます。 | |
public protocol Router { | |
// URLを返却 | |
func url() -> 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
class UINibView: UIView { | |
// コードから初期化はここから | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
comminInit() | |
} | |
// Storyboard/xib から初期化はここから | |
required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) |
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 RObject: Object { | |
// ID | |
dynamic var id = 0 | |
// データを保存。 | |
func save() { | |
let realm = try! Realm() | |
if realm.isInWriteTransaction { | |
if self.id == 0 { self.id = self.createNewId() } | |
realm.add(self, update: 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
class Plist { | |
private var plist:NSMutableDictionary | |
init(name:String) { | |
let filePath = Bundle.main.path(forResource: name, ofType: nil)! | |
let plist = NSMutableDictionary(contentsOfFile: filePath)! | |
self.plist = plist | |
} |
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
- (void) loadStringsFile:(NSString*) file | |
{ | |
// Load default localization dictionary | |
NSString* path = [[CCFileUtils sharedFileUtils] fullPathForFilename:file]; | |
// Load strings file | |
NSDictionary* ser = [NSDictionary dictionaryWithContentsOfFile:path]; | |
// Check that format of file is correct | |
NSAssert([[ser objectForKey:@"fileType"] isEqualToString:@"SpriteBuilderTranslations"], @"Invalid file format for SpriteBuilder localizations"); |
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
// 表示したい製品IDを事前に渡しておきます。 | |
StoreKitAccessor.instance.cacheProducts(productIdentifiers: ["製品IDa", "製品IDb"]) |
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
process :fix_rotate | |
# 画像の向きを調整する。 | |
def fix_rotate | |
manipulate! do |img| | |
img = img.auto_orient | |
img = yield(img) if block_given? | |
img | |
end | |
end |
NewerOlder