Getting started with iOS
UILabel
Change Status Bar Color
Passing Data between View Controllers
Managing the Keyboard
UIButton
UILocalNotification
UIImageView
Checking for Network Connectivity
Accessibility
UITableView
Auto Layout
UIView
UIAlertController
MKMapView
UIColor
NSAttributedString
CAAnimation
UITextView
UINavigationController
Concurrency
CAGradientLayer
UIGestureRecognizer
Custom UIViews from XIB files
Safari Services
UIStackView
UIImage
UIWebView
CALayer
Swift and Objective-C interoperability
NSDate
Custom Fonts
AVSpeechSynthesizer
UIBarButtonItem
UIScrollView
Localization
NSNotificationCenter
UITextField
Networking with Alamofire
UIViewController
iBeacon
CLLocation
NSURLSession
UISwitch
Checking iOS version
Universal Links
UICollectionView
PDF Creation
In-App Purchase
NSTimer
CGContext
UITabBarController
UISearchController
UIActivityViewController
Core Location
FacebookSDK
AFNetworking
CTCallCenter
UIImagePickerController
NSUserDefaults
UIControl - Event Handling with Blocks
UIBezierPath
UIPageViewController
UIAppearance
Push Notifications
Key Value Coding
Initialization idioms
Storyboard
Background Modes and Events
Fastlane
CAShapeLayer
WKWebView
UUID Universally Unique Identifier
Categories
Handling URL Schemes
Realm database
ARC Automatic Reference Counting
UIPickerView
Dynamic Type
NSURL
SWRevealViewController
Snapshot of UIView
DispatchGroup
GCD Grand Central Dispatch
Size Classes and Adaptivity
UIScrollView, AutoLayout
IBOutlets
AWS SDK
Debugging Crashes
UISplitViewController
UISplitViewController
UIDevice
CloudKit
GameplayKit
XCode Build Archive From Command Line
Unit Testing with XCTest
NSData
AVPlayer and AVPlayerViewController
Deep Linking
App Transport Security (ATS)
Core Graphics
Segues
UIDatePicker
NSPredicate
EventKit
NSBundle
SiriKit
Contacts Framework
Dynamically updating a UIStackView
Speech Recognition
NSURLConnection
StoreKit
Code signing
.ipa file to upload on appstore with ApplicationLoader
Resizing UIImage
Size Classes and Adaptivity
MKDistanceFormatter
3D Touch
GameCenter Leaderboards
Keychain
Handle Multiple Environment using Macro
Set View Background
Block
Content Hugging
Google Places API
Navigation Bar
UITextField Delegate
App-wide operations
UILabel text underlining
Cut a UIImage into a circle
Make selective UIView corners rounded
Convert HTML to NSAttributed string and vice versa
Convert NSAttributedString to UIImage
CoreImage Filters
Face Detection Using CoreImageOpenCV
MPMediaPickerDelegate
Graph Coreplot
NSHTTPCookieStorage
FCM Messaging
Create Custom Framework
Custom Keyboard
AirDrop
SLComposeViewController
AirPrint tutorial
UISlider
Carthage
HealthKit
Core SpotLight
UI Testing
Core Motion
QR Code Scanner
plist
NSInvocation
UIRefreshControl TableView
WCSessionDelegate
AppDelegate
App Submission Process
MVVM
UIStoryboard
Basic text file I/O
Text To Speech (TTS)
MPVolumeView
Objective-C Associated Objects
Passing Data between View Controllers
UIPhoenix
Blocks in Queue with MKBlockQueue
Simulator
BackgroundModes
NSArray
OpenGL
UIScrollView with StackView child
Cache online images
MVP Architecture
UIKit Dynamics
Configure Beacons with CoreBluetooth
Core Data
Extension for rich Push Notification
Profiling with Instruments
Application rating review request
MyLayout
UIFont
Simulator Builds
Simulating Location Using GPX files
Custom methods of selection of UITableViewCells
Custom methods of selection of UITableViewCells
UISegmentedControl
SqlCipher integration
Custom UITextField
Custom UITextField
Security
Guideline to architecture patterns
UIFeedbackGenerator
UIKit Dynamics with UICollectionView
Multicast Delegates
Using image assets
UITableViewCell
Runtime in Objective-C
ModelPresentationStyles
CydiaSubstrate tweak
Create a video from images
Codable
FileHandle
NSUserActivity
Rich Notifications
Load images async
Adding Swift bridging header
Creating an App ID
Changing the rootview controller
Attributed text in UILabel
UITableViewController
Contributors

08Convert NSDate that is composed from hour and minute only to a full NSDate

suggest change

There are many cases when one has created an NSDate from only an hour and minute format, i.e: 08:12 that returns from a server as a String and you initiate an NSDate instance by these values only.

The downside for this situation is that your NSDate is almost completely “naked” and what you need to do is to create: day, month, year, second and time zone in order to this object to “play along” with other NSDate types.

For the sake of the example let’s say that hourAndMinute is the NSDate type that is composed from hour and minute format:

Objective-C

NSDateComponents *hourAndMinuteComponents = [calendar components:NSCalendarUnitHour | NSCalendarUnitMinute
                                                         fromDate:hourAndMinute];
NSDateComponents *componentsOfDate = [[NSCalendar currentCalendar] components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear
                                                                     fromDate:[NSDate date]];

NSDateComponents *components = [[NSDateComponents alloc] init];
[components setDay: componentsOfDate.day];
[components setMonth: componentsOfDate.month];
[components setYear: componentsOfDate.year];
[components setHour: [hourAndMinuteComponents hour]];
[components setMinute: [hourAndMinuteComponents minute]];
[components setSecond: 0];
[calendar setTimeZone: [NSTimeZone defaultTimeZone]];

NSDate *yourFullNSDateObject = [calendar dateFromComponents:components];

Now your object is the total opposite of being “naked”.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents