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
//------------------------------------- METHOD 1 ------------------------------------ | |
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) { | |
let index = Int(targetContentOffset.move().x / view.frame.width) | |
let indexPath = IndexPath(item: index, section: 0) | |
print("Current index path: \(indexPath.row)") | |
} | |
//------------------------------------- METHOD 2 ------------------------------------ | |
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { | |
var visibleRect = CGRect() |
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
String friendlyTimeDiff(long timeDifferenceMilliseconds) { | |
long diffSeconds = timeDifferenceMilliseconds / 1000; | |
long diffMinutes = timeDifferenceMilliseconds / (60 * 1000); | |
long diffHours = timeDifferenceMilliseconds / (60 * 60 * 1000); | |
long diffDays = timeDifferenceMilliseconds / (60 * 60 * 1000 * 24); | |
long diffWeeks = timeDifferenceMilliseconds / (60 * 60 * 1000 * 24 * 7); | |
long diffMonths = (long) (timeDifferenceMilliseconds / (60 * 60 * 1000 * 24 * 30.41666666)); | |
long diffYears = timeDifferenceMilliseconds / ((long)60 * 60 * 1000 * 24 * 365); | |
if (diffSeconds < 1) { |
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
Locale.getDefault().getLanguage() ---> en | |
Locale.getDefault().getISO3Language() ---> eng | |
Locale.getDefault().getCountry() ---> US | |
Locale.getDefault().getISO3Country() ---> USA | |
Locale.getDefault().getDisplayCountry() ---> United States | |
Locale.getDefault().getDisplayName() ---> English (United States) | |
Locale.getDefault().toString() ---> en_US | |
Locale.getDefault().getDisplayLanguage()---> English |