Search code examples
swiftnsmutableurlrequest

How to use NSMutableRequest in XCode6


Code:

var request = NSMutableURLRequest(URL: strURl, cachePolicy:NSURLRequestCachePolicy, timeoutInterval:60.0)

What is wrong with my code? How do I solve below error:

Expected member name or constructor call after type name

any help will be appreciated.


Solution

  • NSURLRequestCachePolicy is an enum, you need to pick one of its values. You can get a list of them and what they do here.

    For example, if you want to use the default cache policy, you'd do:

    var request = NSMutableURLRequest(URL: strURl, cachePolicy:NSURLRequestCachePolicy.UseProtocolCachePolicy, timeoutInterval:60.0)