Skip to content

Instantly share code, notes, and snippets.

View koogawa's full-sized avatar
🏠
Working from home

Kosuke Ogawa koogawa

🏠
Working from home
View GitHub Profile
@koogawa
koogawa / file0.rb
Last active April 5, 2018 14:15
Google Maps SDK for iOS の使い方(Swift 4対応) ref: https://qiita.com/koogawa/items/adc2dd19015586bda39b
source 'https://github.com/CocoaPods/Specs.git'
target 'YOUR_APPLICATION_TARGET_NAME_HERE' do
pod 'GoogleMaps'
pod 'GooglePlaces'
end
@koogawa
koogawa / file0.m
Created October 9, 2013 16:19
iOS 7のDynamic Type機能をサポートしてみる ref: http://qiita.com/koogawa@github/items/1011962b444420b854d7
+ (UIFont *)systemFontOfSize:(CGFloat)fontSize;
@koogawa
koogawa / Test.m
Created March 12, 2014 02:41
Objective-Cのいろいろな反復処理
- (void)test
{
NSArray *anArray = @[@"a", @"b", @"c"];
NSDictionary *aDictionary = @{@"key1": @"val1",
@"key2": @"val2",
@"key3": @"val3"};
// for loop
for (int i = 0; i < anArray.count; i++)
@koogawa
koogawa / gist:10624048
Created April 14, 2014 07:25
Dateから相対日時を返す
+ (NSString *)relativeDateStringFromDate:(NSDate *)date
{
NSInteger sec = (int)[[NSDate date] timeIntervalSinceDate:date];
if (sec < 60) {
return @"たった今";
}
else if (sec < 120) {
return @"1分前";
}
@koogawa
koogawa / gist:10624190
Created April 14, 2014 07:28
Safari風ナビゲーションバーアニメーション
#pragma mark - UIScrollView delegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView.contentOffset.y < 0 || scrollView.contentOffset.y > scrollView.contentSize.height - kYCBScreenHeight) {
return;
}
// スクロールによってヘッダを出したり隠したり
if (lastContentOffset_ > scrollView.contentOffset.y)
import UIKit
import MapKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var mapRect: CGRect = CGRect(x:0, y:0,
width:self.view.frame.size.width, height:self.view.frame.size.height)
@koogawa
koogawa / CodePiece.swift
Created July 25, 2015 04:08
テスト:DictionaryからAPIに投げるSTRINGを作るメソッド #cswift #CodePiece
func buildQueryString(fromDictionary parameters: [String: String]) -> String {
var urlVars = [String]()
for (key, var val) in parameters {
val = val.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!
urlVars += [key + "=" + "\(val)"]
}
return (!urlVars.isEmpty ? "?" : "") + join("&", urlVars)
}
@koogawa
koogawa / CodePiece.swift
Created July 28, 2015 01:26
ソースコードのキャプチャ付きツイートテスト #CodePiece
private func buildQueryString(fromDictionary parameters: [String: String]) -> String {
var urlVars = [String]()
for (key, var val) in parameters {
val = val.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!
urlVars += [key + "=" + "\(val)"]
}
return (!urlVars.isEmpty ? "?" : "") + join("&", urlVars)
}
@koogawa
koogawa / CodePiece.swift
Created July 28, 2015 13:11
CodePiece build: 8 テスト #CodePiece
import Realm
class Book : RLMObject {
dynamic var isbn = ""
dynamic var name = ""
dynamic var price = 0
}
@koogawa
koogawa / CodePiece.swift
Created May 15, 2016 03:32
ベニューを取ってきてTableViewに表示するだけなら30行ぐらいで実装できそう #4sqdevjp #CodePiece
import UIKit
import RxSwift
import RxCocoa
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var viewModel = ViewModel()
var dataSource = DataSource()