This file contains hidden or 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)createHole:(UIView *)newView byRect:(CGRect)smallerRect withRadius:(CGFloat)radius andFrameColor:(UIColor *)frameColor { | |
| // plain rectangle path - size of the view | |
| UIBezierPath *outerPath = [UIBezierPath bezierPathWithRect:newView.bounds]; | |
| // rounded corner rectangle path (this will be the "hole") | |
| UIBezierPath *innerPath = [UIBezierPath bezierPathWithRoundedRect:smallerRect cornerRadius:radius]; | |
| [outerPath appendPath:innerPath]; |
This file contains hidden or 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
| // Need: adjustable time-between and distance-between Successive Taps | |
| // | |
| // as far as I can tell, UITapGestureRecognizer only recognizes a Successive Tap if it occurs | |
| // within 0.35 seconds AND within 45 points | |
| // | |
| // Typical Single-Tap and Double-Tap Gesture Recognizer setup... | |
| UITapGestureRecognizer *tapSingle = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotSingleTap:)]; | |
| UITapGestureRecognizer *tapDouble = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotDoubleTap:)]; | |
This file contains hidden or 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
| // change | |
| var bVal: String = "" | |
| // to | |
| var bVal: String? = nil | |
This file contains hidden or 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
| var notification = UILocalNotification() | |
| notification.fireDate = NSDate(timeIntervalSinceNow: 15) | |
| notification.alertBody = "15-second notification" | |
| notification.alertAction = "15 seconds" | |
| notification.soundName = UILocalNotificationDefaultSoundName | |
| notification.userInfo = ["CustomField1": "15"] | |
| UIApplication.sharedApplication().scheduleLocalNotification(notification) | |
This file contains hidden or 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
| var i = 0 | |
| func someLocalFunction() -> String? { | |
| if i > 10 { | |
| return nil | |
| } | |
| i = i + 1 | |
| return "\(i)" | |
| } |
This file contains hidden or 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
| let elements = ["a", "b", "c", "d", "e"] | |
| for (index, element) in elements.enumerate() { | |
| print("i \(index) e \(element)") | |
| if element == elements.last { | |
| print("last = \(element)") | |
| } | |
This file contains hidden or 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
| activityViewController.completionWithItemsHandler = { | |
| (activityType, completed, items, error) in | |
| guard completed else { print("User cancelled."); return } | |
| print("Completed With Activity Type: \(activityType)") | |
| if activityType == UIActivityTypePostToTwitter { | |
| // do something | |
| } else if activityType == UIActivityTypePostToFacebook { |
This file contains hidden or 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
| CFStringRef nm = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleExecutableKey); | |
| NSString *exeName = (__bridge NSString *)nm; | |
| NSFileManager *fm = [[NSFileManager alloc] init]; | |
| NSString *bp = [[NSBundle mainBundle] bundlePath]; | |
| NSString *ep = [NSString stringWithFormat:@"%@/Contents/MacOS/%@", bp, exeName]; | |
| BOOL b = [fm fileExistsAtPath:ep]; |
This file contains hidden or 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
| // two-dimensional array | |
| // should be your Event object... mArray = [[Event]]() | |
| var mArray = [[String]]() | |
| // simulate your allEvents array | |
| var allEvents = ["a 1", "a 2", "a 3", "b 1", "b 2", "c 1", "c 2", "d 1", "d 2"] | |
| // get first "Day" | |
| // yours will be something like: currentDay = getDateFrom(allEvents[0]) |
This file contains hidden or 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
| if thisDay != currentDay { | |
| // if thisDay is NOT equal to currentDay, then it is the first event of the NEXT day | |
| // append the array of the current day's events to the "master" array | |
| mArray.append(oneDaysEvents) | |
| // set currentDay to the day of this event | |
| currentDay = thisDay |