0

I'm trying to make array as parameter but the result is never success.

Here's my parameters:

let params: [String: Any] = [

        "debug": "1",
        "check_in": checkIn,
        "check_out": checkOut,
        "theme": theme,
        "beds": Beds,
        "bedrooms": Bedroom,
        "bathrooms": Bathroom,
        "facility": idFacility,
        "room_type": id,
        "page": 1,
        "take": 10,
        "id_user": sessionId
    ]

    print(params)
    print("THE PARAMS")

if my parameter printed:

[
 "take": 10, 
 "page": 1, 
 "debug": "1", 
 "id_user": 103, 
 "theme": [17, 18, 19], 
 "check_in": "2017-04-01", 
 "check_out": "2017-04-02", 
 "bedrooms": 1, 
 "beds": 1, 
 "room_type": [5, 6, 7], 
 "facility": [11, 12, 13], 
 "bathrooms": 1]

i don't understand, if i send single string or integer it works. But if array, response.result.value never success. I also try to add [String: Any] and still doesn't work.

4
  • The above example you are creating a dictionary and not an array. can you show what do you expect to create? Commented Apr 1, 2017 at 7:55
  • i'm appending value to array and send them as parameter Commented Apr 1, 2017 at 8:02
  • can you show the relevant code with some more explanation of the problem Commented Apr 1, 2017 at 11:23
  • try to make your dictionary with AnyObject, not Any Commented Apr 1, 2017 at 15:53

1 Answer 1

1

i solved it using:

let params: [String: Any] = [

        "debug": "1",
        "city": city,
        "check_in": checkIn,
        "check_out": checkOut,
        "max_guest": maxGuest,
        "theme": String(describing: theme),
        "currency": "IDR",
        "price_min": priceMinimum,
        "price_max": priceMaximum,
        "beds": Beds,
        "bedrooms": Bedroom,
        "bathrooms": Bathroom,
        "facility": String(describing: idFacility),
        "room_type": String(describing: id),
        "page": 1,
        "take": 10,
        "id_user": sessionId
    ]

    print(params)
    print("THE PARAMS")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.