Skip to content

Instantly share code, notes, and snippets.

View jenhausu's full-sized avatar

Will Su jenhausu

View GitHub Profile
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"
class func loadMessage() {
let managerQuery = UserModel.query()!
let userRole = PFRole(withoutDataWithObjectId: "lEGrVrXO0a") // 角色:球場管理
managerQuery.whereKey("userRole", equalTo: userRole)
let caddy = UserModel.current()!
let courseID = caddy.course!
managerQuery.whereKey("course", equalTo: courseID)
@jenhausu
jenhausu / declare.swift
Last active January 15, 2017 05:59
GCD
let queue = DispatchQueue(label: "labelName", qos: .userInteractive, attributes: .concurrent)
@jenhausu
jenhausu / ao.m
Created January 3, 2017 09:28
Array & Dictionary
NSArray *a = @[@"First",@"Second",@"Third"];
NSMutableArray *a2 = [[NSMutableArray alloc]initWithObjects:@"First",@"Second",@"Third",nil];
[a2 addObject:@"Fourth"];
+ (BOOL)password:(NSString *)string {
if ([self checkFormat:string withPattern:@"^([a-zA-Z]+\\d+|\\d+[a-zA-Z]+)[a-zA-Z0-9]*$" matchingOptions:NSRegularExpressionCaseInsensitive]) {
if (string.length >= 6 && string.length <= 12) {
for (NSInteger l = 0 ; l < string.length - 2 ; l++ ) {
NSString *subString = [string substringWithRange:NSMakeRange(l, 3)];
// 檢查數字
for (NSInteger i = 0 ; i <= 9 ; i++ ) {
if ([subString isEqualToString:[NSString stringWithFormat:@"%ld%ld%ld", i, i, i]]) { // 不可連續三個重複的數字
@jenhausu
jenhausu / CCardTableViewCell.m
Last active August 27, 2016 09:57
客製化 UITableViewCell
#import "CCardTableViewCell.h"
@implementation CCardTableViewCell
- (UIView *)card
{
if (!_card) {
_card = [[UIView alloc] init];
}
@jenhausu
jenhausu / CustomCell.m
Last active August 29, 2015 14:23
UITableView
else if (indexPath.section == 1) {
ZeroTableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:@"Cell2" forIndexPath:indexPath];
cell2.text.text = setting[indexPath.section][indexPath.row];
cell2.detailText.text = zero[[userPreferences integerForKey:@"計時器歸零"]];
cell2.detailTextLabel.font = [UIFont systemFontOfSize:10];
cell2.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell2;
if (fetchDataArray.count >= 2 || (fetchDataArray.count == 1 && self.sleepData.wakeUpTime > 0) ) {
} else {
[self dontHaveEnoughDataAlert];
footerText = nil;
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];
}
- (void)dontHaveEnoughDataAlert
@jenhausu
jenhausu / 1.m
Created May 2, 2015 11:45
讀外面的檔案
NSString *path = [[NSBundle mainBundle] pathForResource:@"SleepTypeExplanation"
ofType:@"rtf"];
NSString *fileContent = [NSString stringWithContentsOfFile:path
encoding:NSUTF32StringEncoding
error:&error];
if ([MFMailComposeViewController canSendMail])
{
NSString *emailTitle = @"";
NSString *messageBody = @"";
NSArray *toRecipents = [NSArray arrayWithObject:@"[email protected]"];
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setSubject:emailTitle];
[mailViewController setMessageBody:messageBody isHTML:YES];