Skip to content

Instantly share code, notes, and snippets.

@welbesw
Created June 7, 2016 18:13
Show Gist options
  • Save welbesw/d829ddf0523fd9261febb6d0a17b1b41 to your computer and use it in GitHub Desktop.
Save welbesw/d829ddf0523fd9261febb6d0a17b1b41 to your computer and use it in GitHub Desktop.
public class SalesforceContact {
public var id: String?
public var firstName: String?
public var lastName: String?
public var email: String?
//Method to initialize with JSON dict returned by the API
public init(dictionary: [String : AnyObject]) {
//Iterate over every item in the dictionary
for(key, value) in dictionary {
switch key.lowercaseString {
case "id":
self.id = value as? String
case "firstname":
self.firstName = value as? String
case "lastname":
self.lastName = value as? String
case "email":
self.email = value as? String
default:
//print("SalesforceContact field: \(key)")
break
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment