UIImage(data: NSData) error: Missing argument for parameter 'inBundle' in call

mharris7190

Im storing an NSURL for a Facebook profile picture that looks like "http://graph.facebook.com/(id)/picture?type=large" where id is the user's id.

I want to display the image from that url in a UIImage

I am trying to do this like so:

var data = NSData(contentsOfURL: profilePictureURL)

cell.backgroundImage = UIImage(data: data)

But XCode throws an error on that second line that says:

"Missing argument for parameter 'inBundle' in call" but obviously that's not a parameter in this call. I even tried adding it once before and once after like UIImage(data: data, inBundle: nil) and reversed but it said "extra argument inBundle"

Help please!

**** EDIT ****

Found the problem:

cell.backgroundImage = UIImage(data: data)

should be

cell.backgroundImage.image = UIImage(data: data)
Rob

As you note, you want to set the image property of cell.backgroundImage. Also, you will want to unwrap that optional.

You can do a forced unwrapping:

let data = NSData(contentsOfURL: profilePictureURL)
cell.backgroundImage.image = UIImage(data: data!)

Or, a little safer, and optional binding:

if let data = NSData(contentsOfURL: profilePictureURL) {
    cell.backgroundImage.image = UIImage(data: data)
}

And, if you want to be especially prudent, and do this asynchronously, it would look like:

cell.backgroundImage.image = nil  // initialize it to nil before we go to get image asynchronously

NSURLSession.sharedSession().dataTaskWithURL(profilePictureURL) { data, response, error in
    if data == nil {
        println("dataTaskWithURL error: \(error)")
    } else {
        if let image = UIImage(data: data) {
            dispatch_async(dispatch_get_main_queue()) {
                cell.backgroundImage.image = image
            }
        }
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Missing Argument for parameter #1 in call error

From Dev

error: missing argument for parameter #1 in call (swift)

From Dev

Core Plot with swift getting error : "Missing Argument for Parameter ‘frame’ in call"

From Dev

Missing argument for parameter #1 in call error for function with no params. Swift

From Dev

"Missing argument for parameter 'style' in call" error in creating system UIBarButtonItem

From Dev

Blocks in Swift shows error "Missing argument for parameter #2 in call"

From Dev

Realm/Swift: compilation error: Missing argument for parameter 'forPrimaryKey' in call

From Dev

Missing Argument for parameter ‘coder’ in call

From Dev

Missing argument for parameter 'coder' in call

From Dev

Missing argument for parameter #1 in call

From Dev

Missing argument for parameter 'options' in call

From Dev

"Missing argument parameter 'queue' in call"

From Dev

Missing argument for parameter 'totalBytesWritten' in call

From Dev

MKPolygon initialization error "Missing argument for parameter 'interiorPolygons' in call" / "Extra argument in call"

From Java

Missing argument for parameter #1 in call on a button

From Dev

Swift: Missing argument for parameter 'host' in call

From Dev

NSURL "missing argument for parameter in call" Swift

From Dev

Swift - Missing argument for parameter 'host' in call

From Dev

Swift - Missing argument for parameter "coder" in call

From Dev

Swift Extension, Missing Argument For Parameter #1 In Call

From Dev

Missing argument for parameter #1 in function call

From Dev

Missing argument for parameter #1 in call // Twitter

From Dev

SwiftUI Tabview - Missing argument for parameter 'tab' in call

From Dev

Swift: Missing argument for parameter 'host' in call

From Dev

Swift - Missing argument for parameter "coder" in call

From Dev

Swift : Missing argument for parameter 'locale' in call

From Dev

Missing argument for parameter 'responder' in call swift

From Dev

Missing argument for parameter options in call in swift 2

From Dev

Swift error: missing argument label 'name:' in call

Related Related

  1. 1

    Missing Argument for parameter #1 in call error

  2. 2

    error: missing argument for parameter #1 in call (swift)

  3. 3

    Core Plot with swift getting error : "Missing Argument for Parameter ‘frame’ in call"

  4. 4

    Missing argument for parameter #1 in call error for function with no params. Swift

  5. 5

    "Missing argument for parameter 'style' in call" error in creating system UIBarButtonItem

  6. 6

    Blocks in Swift shows error "Missing argument for parameter #2 in call"

  7. 7

    Realm/Swift: compilation error: Missing argument for parameter 'forPrimaryKey' in call

  8. 8

    Missing Argument for parameter ‘coder’ in call

  9. 9

    Missing argument for parameter 'coder' in call

  10. 10

    Missing argument for parameter #1 in call

  11. 11

    Missing argument for parameter 'options' in call

  12. 12

    "Missing argument parameter 'queue' in call"

  13. 13

    Missing argument for parameter 'totalBytesWritten' in call

  14. 14

    MKPolygon initialization error "Missing argument for parameter 'interiorPolygons' in call" / "Extra argument in call"

  15. 15

    Missing argument for parameter #1 in call on a button

  16. 16

    Swift: Missing argument for parameter 'host' in call

  17. 17

    NSURL "missing argument for parameter in call" Swift

  18. 18

    Swift - Missing argument for parameter 'host' in call

  19. 19

    Swift - Missing argument for parameter "coder" in call

  20. 20

    Swift Extension, Missing Argument For Parameter #1 In Call

  21. 21

    Missing argument for parameter #1 in function call

  22. 22

    Missing argument for parameter #1 in call // Twitter

  23. 23

    SwiftUI Tabview - Missing argument for parameter 'tab' in call

  24. 24

    Swift: Missing argument for parameter 'host' in call

  25. 25

    Swift - Missing argument for parameter "coder" in call

  26. 26

    Swift : Missing argument for parameter 'locale' in call

  27. 27

    Missing argument for parameter 'responder' in call swift

  28. 28

    Missing argument for parameter options in call in swift 2

  29. 29

    Swift error: missing argument label 'name:' in call

HotTag

Archive