Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

biteupco/Adam

Repository files navigation

Adam

(New) Client for gobbl Old one is here https://github.com/gobbl/adam-deprecated

##Gobbl Food Next Door

Dependencies

  1. Facebook SDK
  2. Alamofire
  3. SwiftyJSON
  4. (optional)Mixpanel SDK

Before Run

Pod install. We manage Alamofire and SwiftyJSON by Cocoapods. So before we bagan we mus run

pod install or pod update if you already installed it.

To able to work with current version of server side we have to midify some of the Alamofire library: in order to meet the server's request prameter format.

  1. We add this function.
func queryArrayComponents(key: String, _ value: AnyObject) -> [(String, String)] {
  var components: [(String, String)] = []
  if let array = value as? [AnyObject] {
    var arrayVar:String = ""
    for value in array {
      arrayVar += escape("\(value)")
      arrayVar += ","
    }
    arrayVar.removeAtIndex(arrayVar.endIndex.predecessor())
    components.extend([(escape(key),arrayVar)])
  }
  return components
}
  1. Inside the encode funciton we add the if condition so when we found the batch request(in Array) we shall use queryArrayComponets() instead.
func query(parameters: [String: AnyObject]) -> String {
  var isArray = false
  var components: [(String, String)] = []
  for key in sorted(Array(parameters.keys), <) {
    let value: AnyObject! = parameters[key]

    if let array = value as? [AnyObject] {
      isArray = true
      var QueryComponent = self.queryArrayComponents(key, value)
      components += QueryComponent
    } else {
      var QueryComponent = self.queryComponents(key, value)
      components += QueryComponent
    }
      
  }
  return join("&", components.map{"\($0)=\($1)"})
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published