[Question] What's the ideal way to create a Web Client class using Alamofire?
I'm finally diving into Swift and starting my first project in it. My first need is for a API Client class. Previously in Objective-C I would create something like this. A singleton object with some basic GET, POST, calls. More on that here.
Anyway, now I'm trying to create a Web Client in Swift but am getting hung up. A few questions
-
Does this look correct on how to initially setup the class?
class APIClient : NSObject { static let sharedInstance = APIClient() private override init() {} //this prevents others from using the default initializer for this class, as its a singleton
let baseURL = "https://www.googleapis.com/"}
-
Can someone write up for example an equivalent function for say the
fetchDictionaryWithURLString:success:failure:(using Alamofire) from my code here so I can make some mental mappings.
Thanks.
Posted Apr 15, 2016, 2:16 AM UTC