objective-cnsuinteger

Get an error when I try to pass an element to an HTTP request


error:

collection element of type nsuinteger aka unsigned long is not an objective c object

I am trying to make an http request to stripe. This is what the params look like

@"card": card.number, @"exp_month": card.expMonth, @"exp_year": card.expYear, @"cvc": card.cvc

The card.expMonth is whats causing the error. I tried adding (unsigned long) infront, but got the error

collection element of type 'unsigned long' is not an objective c object

What can I do to send the month element?


Solution

  • The "code" you posted isn't very clear. But it seems that card.expMonth is an NSUInteger. You need to wrap such primitive types in NSNumber objects.

    Do that by changing:

    card.expMonth
    

    to

    @(card.expMonth)
    

    Do this for any of the values that represent a primitive number type.