RandomUser
public class RandomUser
Class that interacts with the RandomUser API to generate random users
-
Singleton
Declaration
Swift
public static let shared: RandomUser
-
Get one or more users from RandomUser API (https://www.randomuser.me/documentation)
Declaration
Swift
public func getUsers(results: Int = 1, gender: String = "both", nationality: String = "", _ completionHandler: @escaping (_ data: Users?, _ error: Error?) -> Void)
Parameters
results
(optional) number of generated users to fetch in one request. Max is 5000. Default is 1.
gender
(optional) specify whether you would like to have only male/female users generated. Valid values for the gender parameter are “male” or “female”, or you may leave the parameter blank. Any other value will cause the service to return both male and female users. Default is both.
nationality
(optional) specify nationality of generator users via comma separated values. Pictures won’t be affected by this, but data such as location, cell/home phone, id, etc. will be more appropriate. Available nationalities for api v1.2 include: AU, BR, CA, CH, DE, DK, ES, FI, FR, GB, IE, IR, NO, NL, NZ, TR, US Default is random.