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
- (NSDate*)dateAfterWeeks:(NSInteger)weeks fromDate:(NSDate*)date | |
{ | |
NSCalendar* calendar = [NSCalendar currentCalendar]; | |
NSDateComponents* someWeeksComponent = [[NSDateComponents alloc] init]; | |
someWeeksComponent.week = weeks; | |
return [calendar dateByAddingComponents:someWeeksComponent toDate:date options: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
- (NSDate*)dateOfNextWeekday:(NSInteger)weekday fromDate:(NSDate*)date | |
{ | |
NSCalendar* calendar = [NSCalendar currentCalendar]; | |
// 渡された日付から曜日を取り出します。 | |
NSDateComponents* baseComponents = [calendar components:NSWeekdayCalendarUnit fromDate:date]; | |
NSDateComponents* addingComponents = [[NSDateComponents alloc] init]; | |
// 指定された曜日だけ進めます。 | |
NSInteger addingDay = weekday - baseComponents.weekday; |
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
infoPlistFile=${TEMP_DIR}/Preprocessed-Info.plist | |
timeData=`date +"%H%M%S"` | |
/usr/libexec/PlistBuddy -c "Set:CFBundleDisplayName $timeData" "${infoPlistFile}" |
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
infoPlistFile="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" | |
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${infoPlistFile}") | |
buildNumber=$((${buildNumber%%.*} + 1)) | |
/usr/libexec/PlistBuddy -c "Set:CFBundleVersion $buildNumber" "${infoPlistFile}" |
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
protocol Protocol { | |
init() | |
} | |
struct Struct : Protocol, Printable { | |
init() { | |
} |
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
protocol FloatingType { | |
var floatValue:Double { get } | |
} | |
extension CGFloat : FloatingType { | |
var floatValue:Double { | |
return self.native |
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
guard let string = string where !string.isEmpty else { | |
} |
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
struct MyStruct { | |
func hello() { | |
print("hello world") | |
} | |
} |
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
// この場合はエラー | |
// 大域で、同じ変数名で Optional Binding するとビルドが通らない(string が Optional のまま) | |
guard let string = string where !string.isEmpty else { | |
print("GUARD") | |
exit(0) | |
} | |
// この場合は OK | |
// 大域でも別の変数名で Binding すると通る(新しい変数 s なら Optional が解けている) |
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
// 大域だと先に 1 が表示される | |
defer { | |
print(1) | |
} | |
print(2) | |
// 関数だと先に 2 が表示される | |
func test() { |
OlderNewer