Skip to content

Instantly share code, notes, and snippets.

- (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];
// 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:)];
// change
var bVal: String = ""
// to
var bVal: String? = nil
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)
var i = 0
func someLocalFunction() -> String? {
if i > 10 {
return nil
}
i = i + 1
return "\(i)"
}
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)")
}
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 {
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];
// 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])
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