How to compare two NSDates: Which is more recent?

Let’s assume two dates: NSDate *date1; NSDate *date2; Then the following comparison will tell which is earlier/later/same: if ([date1 compare:date2] == NSOrderedDescending) { NSLog(@”date1 is later than date2″); } else if ([date1 compare:date2] == NSOrderedAscending) { NSLog(@”date1 is earlier than date2″); } else { NSLog(@”dates are the same”); } Please refer to the NSDate class … Read more

Swipe to Delete and the “More” button (like in Mail app on iOS 7)

How to Implement It looks like iOS 8 opens up this API. Hints of such functionality are present in Beta 2. To get something working, implement the following two methods on your UITableView’s delegate to get the desired effect (see gist for an example). – tableView:editActionsForRowAtIndexPath: – tableView:commitEditingStyle:forRowAtIndexPath: Known Issues The documentation says tableView:commitEditingStyle:forRowAtIndexPath is: … Read more

Prevent segue in prepareForSegue method?

It’s possible in iOS 6 and later: You have to implement the method – (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender In your view controller. You do your validation there, and if it’s OK then return YES; if it’s not then return NO; and the prepareForSegue is not called. Note that this method doesn’t get called automatically when triggering … Read more

“Unknown class in Interface Builder file” error at runtime

Despite the “Unknown class MyClass in Interface Builder file.” error printed at runtime, this issue has nothing to do with Interface Builder, but rather with the linker, which is not linking a class because no code uses it directly. When the .nib data (compiled from the .xib) is loaded at runtime, MyClass is referenced using … Read more

How do you add an in-app purchase to an iOS application?

Swift Users Swift users can check out My Swift Answer for this question.Or, check out Yedidya Reiss’s Answer, which translates this Objective-C code to Swift. Objective-C Users The rest of this answer is written in Objective-C App Store Connect Go to appstoreconnect.apple.com and log in Click My Apps then click the app you want do … Read more

Hide separator line on one UITableViewCell

in viewDidLoad, add this line: self.tableView.separatorColor = [UIColor clearColor]; and in cellForRowAtIndexPath: for iOS lower versions if(indexPath.row != self.newCarArray.count-1){ UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(0, 44, 320, 2)]; line.backgroundColor = [UIColor redColor]; [cell addSubview:line]; } for iOS 7 upper versions (including iOS 8) if (indexPath.row == self.newCarArray.count-1) { cell.separatorInset = UIEdgeInsetsMake(0.f, cell.bounds.size.width, 0.f, 0.f); }

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