How do I add 1 day to an NSDate?

Swift 5.0 : var dayComponent = DateComponents() dayComponent.day = 1 // For removing one day (yesterday): -1 let theCalendar = Calendar.current let nextDate = theCalendar.date(byAdding: dayComponent, to: Date()) print(“nextDate : \(nextDate)”) Objective C : NSDateComponents *dayComponent = [[NSDateComponents alloc] init]; dayComponent.day = 1; NSCalendar *theCalendar = [NSCalendar currentCalendar]; NSDate *nextDate = [theCalendar dateByAddingComponents:dayComponent toDate:[NSDate date] … Read more

How to use Auto Layout to move other views when a view is hidden?

It is possible, but you’ll have to do a little extra work. There are a couple conceptual things to get out of the way first: Hidden views, even though they don’t draw, still participate in Auto Layout and usually retain their frames, leaving other related views in their places. When removing a view from its … Read more

How to write iOS app purely in C

Damn, it took me a while but I got it: main.c: #include <CoreFoundation/CoreFoundation.h> #include <objc/runtime.h> #include <objc/message.h> // This is a hack. Because we are writing in C, we cannot out and include // <UIKit/UIKit.h>, as that uses Objective-C constructs. // however, neither can we give the full function declaration, like this: // int UIApplicationMain … Read more

UILongPressGestureRecognizer gets called twice when pressing down

UILongPressGestureRecognizer is a continuous event recognizer. You have to look at the state to see if this is the start, middle or end of the event and act accordingly. i.e. you can throw away all events after the start, or only look at movement as you need. From the Class Reference: Long-press gestures are continuous. … Read more

How do you add multi-line text to a UIButton?

For iOS 6 and above, use the following to allow multiple lines: button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; // you probably want to center it button.titleLabel.textAlignment = NSTextAlignmentCenter; // if you want to [button setTitle: @”Line1\nLine2″ forState: UIControlStateNormal]; For iOS 5 and below use the following to allow multiple lines: button.titleLabel.lineBreakMode = UILineBreakModeWordWrap; // you probably want to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)