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
- (IBAction)click:(id)sender | |
{ | |
// 1. 載入特定的 Storyboard | |
UIStoryboard *board = [UIStoryboard storyboardWithName:@"SecondStoryboard" bundle:nil]; | |
// 2. 初始化這個 storyboard 裡的某一個 view controller | |
MyCustomViewController *vc = [board instantiateViewControllerWithIdentifier:@"My Custom View Controller"]; | |
// 3. 顯示這個 view controller | |
[self presentModalViewController:vc animated:NO]; | |
} |
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
// 在玩遊戲的 View Controller | |
#import "PlayGameViewController.h" | |
#import "ScoreManager.h" | |
// 遊戲結束了,有個方法專門用來處理後續動作 | |
- (void)gameOver | |
{ | |
// 1. 取得 score manager | |
ScoreManager *scoreManager = [ScoreManager sharedInstance]; |
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)scrollViewDidScroll:(UIScrollView *)scrollView | |
{ | |
// 或許你會有一個變數來判斷目前是否正在載入資料 | |
if (isLoading) | |
return; | |
// 判斷滾到哪裡的時候要自動載入更多,這可以依需求調整 | |
if ((scrollView.contentOffset.y > scrollView.contentSize.height - scrollView.frame.size.height * 2) && | |
// 或許你會有其他辦法來判斷是否還有更多資料可以載入 | |
(currentPage < pageCount)) |
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
{ | |
"bold_folder_labels": true, | |
"ensure_newline_at_eof_on_save": true, | |
"fade_fold_buttons": true, | |
"file_exclude_patterns": | |
[ | |
".DS_Store", | |
".gitkeep", | |
"dump.rdb" | |
], |
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
#===============# | |
# For Windows | |
#===============# | |
# Windows image file caches | |
Thumbs.db | |
# Folder config file | |
Desktop.ini | |
# Recycle Bin used on file shares |
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 <CoreText/CoreText.h> // Don't forget to import CoreText | |
NSArray *familyNames = [UIFont familyNames]; | |
for (NSString *familyName in familyNames) { | |
NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName]; | |
for (NSString *fontName in fontNames) { | |
CTFontRef fontRef = CTFontCreateWithName((__bridge CFStringRef)(fontName), 16, NULL); | |
NSString *displayName = CFBridgingRelease(CTFontCopyDisplayName(fontRef)); // Here's the magic... | |
NSLog(@"%@", displayName); | |
} |
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
# | |
# Uncrustify Configuration File | |
# File Created With UncrustifyX 0.4.3 (252) | |
# | |
# Alignment | |
# --------- | |
## Alignment |
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
// | |
// UIDeviceHardware.h | |
// | |
// Used to determine EXACT version of device software is running on. | |
#import <Foundation/Foundation.h> | |
@interface UIDeviceHardware : NSObject | |
- (NSString *) platform; |
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
- (RACSignal *)fetchSomething { | |
NSString *path = @"path/to/endpoint"; | |
@weakify(self); | |
RACSignal *signal = [RACSignal createSignal:^RACDisposable *(id < RACSubscriber > subscriber) { | |
@strongify(self); | |
[[self rac_GET:path parameters:nil] subscribeNext:^(id responseObject) { | |
NSError *error = nil; | |
NSArray *results = [MTLJSONAdapter modelsOfClass:[XXXModel class] fromJSONArray:responseObject error:&error]; | |
if (error) { |
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
// | |
// Reference: | |
// https://khanlou.com/2016/07/implementing-dictionary-in-swift/ | |
// | |
import Foundation | |
class Item<Key: Hashable, Value> { | |
let key: Key | |
var value: Value |