URLRequest
is an overlay for NSURLRequest
so you are correct in thinking that they are essentially the same thing. They are different classes but they are intended to provide the same functionality. The NS version is more of a legacy API that was a holdover from Objective-C and the non-NS version is the 'swifty' one.
Here is a quote from apple's own documentation on NSURLRequest:
The Swift overlay to the Foundation framework provides the URLRequest structure, which bridges to the NSURLRequest class and its mutable > subclass,
NSMutableURLRequest. For more information about value types, see Working with Cocoa Frameworks in Using Swift with Cocoa and Objective-C (Swift 4).
Additionally, here is the actual swift proposal from when they decided to drop NS from a number of classes with Foundation.
https://github.com/apple/swift-evolution/blob/master/proposals/0086-drop-foundation-ns.md
Essentially, if you are using Objective-C you use the NS versions. If you are using Swift you want to default to using the Non-NS versions and only use the NS version when you are trying to bridge to Objective-C or a specific library is requiring you to use the NS version.
URLRequest
as it was made using the Swift API Design Guidelines. Most Swift APIs useURLRequest
now, so if you useNSURLRequest
you'll have to typecast toURLRequest
– Telpher