• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Trouble With NSURLSession...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble With NSURLSession...


  • Subject: Re: Trouble With NSURLSession...
  • From: Greg Parker <email@hidden>
  • Date: Tue, 16 Jun 2015 19:57:24 -0700

> On Jun 16, 2015, at 7:45 PM, Peters, Brandon <email@hidden> wrote:
>
> Here is the exact compiler message:
>
> swift:20:26: Cannot find an initializer for type 'NSURLSession' that accepts an argument list of type '(configuration: NSURLSessionConfiguration, delegate: HSNDataManager.Type, delegateQueue: nil)'
>
> Hello,
>
> I am creating a class to handle downloading my app’s data. I am using Xcode with iOS 8.4 SDK and I keep getting from the compiler that there is no initializer for NSURLSession that accepts the list of arguments I am using:
>
>
> import UIKit
>
> class HSNDataManager: NSObject, NSURLSessionDelegate, NSURLSessionTaskDelegate,
> NSURLSessionDownloadDelegate {
>
>   static let dataManager = HSNDataManager()
>
>   class func getRemoteData() {
>       // url session configuration
>       let urlSessionConfiguration = NSURLSessionConfiguration.defaultSessionConfiguration()
>       // create url session for downloading our sites database file
>       var urlSession = NSURLSession(configuration: urlSessionConfiguration, delegate: self, delegateQueue: nil)

You're inside a class func. `self` is the class object for class HSNDataManager. That class object is not a valid delegate. Presumably you need to pass an instance of HSNDataManager as the delegate object.


--
Greg Parker     email@hidden     Runtime Wrangler



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >Trouble With NSURLSession... (From: "Peters, Brandon" <email@hidden>)

  • Prev by Date: Re: Trouble With NSURLSession...
  • Next by Date: Re: Language options: Objective-C, Swift, C or C++?
  • Previous by thread: Re: Trouble With NSURLSession...
  • Next by thread: access modifiers in protocols
  • Index(es):
    • Date
    • Thread