Learn how to add parameters to your API request
The collection view example looks cool, but there's almost no real life usage for it without sending parameters, both static & dynamic.
It's super easy to add your own parameters to any request, just type them in either Header
or Body
fields in your attribute inspector.
Send parameters by stating the key followed by an equal sign and the value.
Example:key=value
To add multiple parameters add &
sign between them.
Example:key1=value1&key2=value
Abstract Layer will automatically do the URL encoding for you if it's a
GET
http method, and format them as JSON if it'sPOST
,PUT
,PATCH
, orDELETE
http method.
What if you want to send dynamic parameters like current user's location?
This is were you send your own case-specific parameters.
Just wrap your parameters with double curly braces like this {{latitude}}.
But where does Abstract Layer read the value of that variable from? You pass it by calling ALStore:
let latitude = // Latitude value you read from GPS
ALStore.sharedInstance().setValue(latitude, forKey: "latitude")
NSString *latitude = ... // Latitude value you read from GPS
[[CPStore sharedInstance] setValue:latitude forKey:@"latitude"];
Don't forget to #import <AbstractLayer/ALStore.h>
in your class.
It's as simple as that.
Abstract Layer supports lots of features on the ALCollectionView
, so make sure to check the rest out!
As for customizability, Abstract Layer has a dedicated section for it.