Alamofire general request
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Could you help me please with this
I'm trying to pull data from API using Alamofire. Is it possible to pull simple data like ["title"] and Image in the same request and populate it in table view?
Here's my code:
Alamofire.request(baseURL).responseJSON { (response) in
switch response.result {
case .success:
if let value = response.result.value{
let json = JSON(value)
json.forEach({ (temp) in
let title = temp.1["title"].stringValue
let run = temp.1["run"].stringValue
let image = temp.1["thumb"].stringValue
let newmodel = Schedule(title: title, run: run, image: image)
self.scheduleArray.append(newmodel)
})
}
case .failure(let error):
print(error.localizedDescription)
}
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
swift request alamofire
|
show 1 more comment
Could you help me please with this
I'm trying to pull data from API using Alamofire. Is it possible to pull simple data like ["title"] and Image in the same request and populate it in table view?
Here's my code:
Alamofire.request(baseURL).responseJSON { (response) in
switch response.result {
case .success:
if let value = response.result.value{
let json = JSON(value)
json.forEach({ (temp) in
let title = temp.1["title"].stringValue
let run = temp.1["run"].stringValue
let image = temp.1["thumb"].stringValue
let newmodel = Schedule(title: title, run: run, image: image)
self.scheduleArray.append(newmodel)
})
}
case .failure(let error):
print(error.localizedDescription)
}
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
swift request alamofire
"Is it possible to pull simple data like" - Yes, anything a HTTP server can produce, you can consume - which raises the questions over, what is the server responding with? You seem to trying to parse some JSON, is the server returning a JSON response? You question is to general and doesn't point to a specific problem or issue. Were you using a previous approach (URLSession
?) which was working and this isn't? What URL are you communicating with? What are the inputs and expected outputs? Are you having trouble parsing the result or populating the table?
– MadProgrammer
Nov 21 '18 at 21:06
Oh no, I don't have problem with populating data. I just wanted to write 1 Alamofire request for simple objects and image data as well
– Акарыс Турганбекулы
Nov 21 '18 at 21:08
So you have, two requests to make that return different data sets and you want to some how combine them?
– MadProgrammer
Nov 21 '18 at 21:10
Yes, something like Alamofire.request(baseURL).response { (response, error, data) in
– Акарыс Турганбекулы
Nov 21 '18 at 21:12
This might be beyond the scope of your intention, but I'd consider looking something like "PromiseKit" or "Hydra", which would manage the execution of two async operations and a much more elegant way, other then using a bunch of semaphores and other locking/notification mechanisms ... just saying
– MadProgrammer
Nov 21 '18 at 21:14
|
show 1 more comment
Could you help me please with this
I'm trying to pull data from API using Alamofire. Is it possible to pull simple data like ["title"] and Image in the same request and populate it in table view?
Here's my code:
Alamofire.request(baseURL).responseJSON { (response) in
switch response.result {
case .success:
if let value = response.result.value{
let json = JSON(value)
json.forEach({ (temp) in
let title = temp.1["title"].stringValue
let run = temp.1["run"].stringValue
let image = temp.1["thumb"].stringValue
let newmodel = Schedule(title: title, run: run, image: image)
self.scheduleArray.append(newmodel)
})
}
case .failure(let error):
print(error.localizedDescription)
}
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
swift request alamofire
Could you help me please with this
I'm trying to pull data from API using Alamofire. Is it possible to pull simple data like ["title"] and Image in the same request and populate it in table view?
Here's my code:
Alamofire.request(baseURL).responseJSON { (response) in
switch response.result {
case .success:
if let value = response.result.value{
let json = JSON(value)
json.forEach({ (temp) in
let title = temp.1["title"].stringValue
let run = temp.1["run"].stringValue
let image = temp.1["thumb"].stringValue
let newmodel = Schedule(title: title, run: run, image: image)
self.scheduleArray.append(newmodel)
})
}
case .failure(let error):
print(error.localizedDescription)
}
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
swift request alamofire
swift request alamofire
asked Nov 21 '18 at 21:02
Акарыс ТурганбекулыАкарыс Турганбекулы
136
136
"Is it possible to pull simple data like" - Yes, anything a HTTP server can produce, you can consume - which raises the questions over, what is the server responding with? You seem to trying to parse some JSON, is the server returning a JSON response? You question is to general and doesn't point to a specific problem or issue. Were you using a previous approach (URLSession
?) which was working and this isn't? What URL are you communicating with? What are the inputs and expected outputs? Are you having trouble parsing the result or populating the table?
– MadProgrammer
Nov 21 '18 at 21:06
Oh no, I don't have problem with populating data. I just wanted to write 1 Alamofire request for simple objects and image data as well
– Акарыс Турганбекулы
Nov 21 '18 at 21:08
So you have, two requests to make that return different data sets and you want to some how combine them?
– MadProgrammer
Nov 21 '18 at 21:10
Yes, something like Alamofire.request(baseURL).response { (response, error, data) in
– Акарыс Турганбекулы
Nov 21 '18 at 21:12
This might be beyond the scope of your intention, but I'd consider looking something like "PromiseKit" or "Hydra", which would manage the execution of two async operations and a much more elegant way, other then using a bunch of semaphores and other locking/notification mechanisms ... just saying
– MadProgrammer
Nov 21 '18 at 21:14
|
show 1 more comment
"Is it possible to pull simple data like" - Yes, anything a HTTP server can produce, you can consume - which raises the questions over, what is the server responding with? You seem to trying to parse some JSON, is the server returning a JSON response? You question is to general and doesn't point to a specific problem or issue. Were you using a previous approach (URLSession
?) which was working and this isn't? What URL are you communicating with? What are the inputs and expected outputs? Are you having trouble parsing the result or populating the table?
– MadProgrammer
Nov 21 '18 at 21:06
Oh no, I don't have problem with populating data. I just wanted to write 1 Alamofire request for simple objects and image data as well
– Акарыс Турганбекулы
Nov 21 '18 at 21:08
So you have, two requests to make that return different data sets and you want to some how combine them?
– MadProgrammer
Nov 21 '18 at 21:10
Yes, something like Alamofire.request(baseURL).response { (response, error, data) in
– Акарыс Турганбекулы
Nov 21 '18 at 21:12
This might be beyond the scope of your intention, but I'd consider looking something like "PromiseKit" or "Hydra", which would manage the execution of two async operations and a much more elegant way, other then using a bunch of semaphores and other locking/notification mechanisms ... just saying
– MadProgrammer
Nov 21 '18 at 21:14
"Is it possible to pull simple data like" - Yes, anything a HTTP server can produce, you can consume - which raises the questions over, what is the server responding with? You seem to trying to parse some JSON, is the server returning a JSON response? You question is to general and doesn't point to a specific problem or issue. Were you using a previous approach (
URLSession
?) which was working and this isn't? What URL are you communicating with? What are the inputs and expected outputs? Are you having trouble parsing the result or populating the table?– MadProgrammer
Nov 21 '18 at 21:06
"Is it possible to pull simple data like" - Yes, anything a HTTP server can produce, you can consume - which raises the questions over, what is the server responding with? You seem to trying to parse some JSON, is the server returning a JSON response? You question is to general and doesn't point to a specific problem or issue. Were you using a previous approach (
URLSession
?) which was working and this isn't? What URL are you communicating with? What are the inputs and expected outputs? Are you having trouble parsing the result or populating the table?– MadProgrammer
Nov 21 '18 at 21:06
Oh no, I don't have problem with populating data. I just wanted to write 1 Alamofire request for simple objects and image data as well
– Акарыс Турганбекулы
Nov 21 '18 at 21:08
Oh no, I don't have problem with populating data. I just wanted to write 1 Alamofire request for simple objects and image data as well
– Акарыс Турганбекулы
Nov 21 '18 at 21:08
So you have, two requests to make that return different data sets and you want to some how combine them?
– MadProgrammer
Nov 21 '18 at 21:10
So you have, two requests to make that return different data sets and you want to some how combine them?
– MadProgrammer
Nov 21 '18 at 21:10
Yes, something like Alamofire.request(baseURL).response { (response, error, data) in
– Акарыс Турганбекулы
Nov 21 '18 at 21:12
Yes, something like Alamofire.request(baseURL).response { (response, error, data) in
– Акарыс Турганбекулы
Nov 21 '18 at 21:12
This might be beyond the scope of your intention, but I'd consider looking something like "PromiseKit" or "Hydra", which would manage the execution of two async operations and a much more elegant way, other then using a bunch of semaphores and other locking/notification mechanisms ... just saying
– MadProgrammer
Nov 21 '18 at 21:14
This might be beyond the scope of your intention, but I'd consider looking something like "PromiseKit" or "Hydra", which would manage the execution of two async operations and a much more elegant way, other then using a bunch of semaphores and other locking/notification mechanisms ... just saying
– MadProgrammer
Nov 21 '18 at 21:14
|
show 1 more comment
1 Answer
1
active
oldest
votes
You can get the base data at first and after that get every image with single request
get base data with this code :
func POSTWithLoad(urlString: String,paramaters: [String: AnyObject]? = nil,success:@escaping (_ responseObject: AnyObject?) -> Void ,failure: @escaping (_ error: String?) -> Void ) {
Alamofire.request(baseUrlDev+urlString, method: .post, parameters:paramaters, encoding: URLEncoding.default, headers: headers).responseJSON(completionHandler: { (responseData) in
if (responseData.result.error == nil && responseData.result.isSuccess == true) {
//success
success(responseData)
} else {
//fauiler
failure("UnKnowen Data")
}
})
}
and use this for getImage :
func getImage(link : String , completion : @escaping (_ imageWithLink : (link : String,image : UIImage)) -> Void){
var image = UIImage(named: "placeholder")
URLSession.shared.dataTask(with: NSURL(string: link.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!)! as URL, completionHandler: { (data, response, error) -> Void in
if error != nil {
print("errorLoadIamge : "+link)
//completion(image)
print(error)
return
}
DispatchQueue.main.async(execute: { () -> Void in
let mimage = UIImage(data: data!)
if(mimage != nil){
image = mimage!
completion((link : link , image : image))
print("successLoadIamge : "+link)
return
}
})
}).resume()
}
then can use it in your ViewContoller like this :
let products : [Product] =
let productImages : [String] =
POSTWithLoad(urlString: "YApiLink" , paramaters: requestParameters as [String : AnyObject]?, success: { (successObject) in
products = Mapper<Product>().mapArray(JSONObject : successObject)
productsImages =
print(successObject)
}, failure :{ (failureObject) in
print(failureObject)
}
)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let product = products[indexPath.row]
let cell = YourTableView.dequeueReusableCell(withIdentifier: "CellIdentifier", for: indexPath) as! YourTableViewCell
if let imageAndLink = productsImages.first(where: { $0.link == cell.product?.productImage})
{cell.pImage?.image = imageAndLink.image}
else{ cell.pImage.image = UIImage(named: "placeholder")
getImage(link: cell.product?.productImage ?? "", completion: {(newImage) in
DispatchQueue.main.async {
if self.productsImages.first(where: { $0.link == newImage.link}) == nil
{
self.productsImages.append(ProductImage(link : newImage.link , image : newImage.image) )
}
if cell.product?.productImage == newImage.link{
cell.pImage.image = newImage.image
}
}
})
}
}
Thank you very much
– Акарыс Турганбекулы
Nov 22 '18 at 14:03
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420432%2falamofire-general-request%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can get the base data at first and after that get every image with single request
get base data with this code :
func POSTWithLoad(urlString: String,paramaters: [String: AnyObject]? = nil,success:@escaping (_ responseObject: AnyObject?) -> Void ,failure: @escaping (_ error: String?) -> Void ) {
Alamofire.request(baseUrlDev+urlString, method: .post, parameters:paramaters, encoding: URLEncoding.default, headers: headers).responseJSON(completionHandler: { (responseData) in
if (responseData.result.error == nil && responseData.result.isSuccess == true) {
//success
success(responseData)
} else {
//fauiler
failure("UnKnowen Data")
}
})
}
and use this for getImage :
func getImage(link : String , completion : @escaping (_ imageWithLink : (link : String,image : UIImage)) -> Void){
var image = UIImage(named: "placeholder")
URLSession.shared.dataTask(with: NSURL(string: link.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!)! as URL, completionHandler: { (data, response, error) -> Void in
if error != nil {
print("errorLoadIamge : "+link)
//completion(image)
print(error)
return
}
DispatchQueue.main.async(execute: { () -> Void in
let mimage = UIImage(data: data!)
if(mimage != nil){
image = mimage!
completion((link : link , image : image))
print("successLoadIamge : "+link)
return
}
})
}).resume()
}
then can use it in your ViewContoller like this :
let products : [Product] =
let productImages : [String] =
POSTWithLoad(urlString: "YApiLink" , paramaters: requestParameters as [String : AnyObject]?, success: { (successObject) in
products = Mapper<Product>().mapArray(JSONObject : successObject)
productsImages =
print(successObject)
}, failure :{ (failureObject) in
print(failureObject)
}
)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let product = products[indexPath.row]
let cell = YourTableView.dequeueReusableCell(withIdentifier: "CellIdentifier", for: indexPath) as! YourTableViewCell
if let imageAndLink = productsImages.first(where: { $0.link == cell.product?.productImage})
{cell.pImage?.image = imageAndLink.image}
else{ cell.pImage.image = UIImage(named: "placeholder")
getImage(link: cell.product?.productImage ?? "", completion: {(newImage) in
DispatchQueue.main.async {
if self.productsImages.first(where: { $0.link == newImage.link}) == nil
{
self.productsImages.append(ProductImage(link : newImage.link , image : newImage.image) )
}
if cell.product?.productImage == newImage.link{
cell.pImage.image = newImage.image
}
}
})
}
}
Thank you very much
– Акарыс Турганбекулы
Nov 22 '18 at 14:03
add a comment |
You can get the base data at first and after that get every image with single request
get base data with this code :
func POSTWithLoad(urlString: String,paramaters: [String: AnyObject]? = nil,success:@escaping (_ responseObject: AnyObject?) -> Void ,failure: @escaping (_ error: String?) -> Void ) {
Alamofire.request(baseUrlDev+urlString, method: .post, parameters:paramaters, encoding: URLEncoding.default, headers: headers).responseJSON(completionHandler: { (responseData) in
if (responseData.result.error == nil && responseData.result.isSuccess == true) {
//success
success(responseData)
} else {
//fauiler
failure("UnKnowen Data")
}
})
}
and use this for getImage :
func getImage(link : String , completion : @escaping (_ imageWithLink : (link : String,image : UIImage)) -> Void){
var image = UIImage(named: "placeholder")
URLSession.shared.dataTask(with: NSURL(string: link.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!)! as URL, completionHandler: { (data, response, error) -> Void in
if error != nil {
print("errorLoadIamge : "+link)
//completion(image)
print(error)
return
}
DispatchQueue.main.async(execute: { () -> Void in
let mimage = UIImage(data: data!)
if(mimage != nil){
image = mimage!
completion((link : link , image : image))
print("successLoadIamge : "+link)
return
}
})
}).resume()
}
then can use it in your ViewContoller like this :
let products : [Product] =
let productImages : [String] =
POSTWithLoad(urlString: "YApiLink" , paramaters: requestParameters as [String : AnyObject]?, success: { (successObject) in
products = Mapper<Product>().mapArray(JSONObject : successObject)
productsImages =
print(successObject)
}, failure :{ (failureObject) in
print(failureObject)
}
)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let product = products[indexPath.row]
let cell = YourTableView.dequeueReusableCell(withIdentifier: "CellIdentifier", for: indexPath) as! YourTableViewCell
if let imageAndLink = productsImages.first(where: { $0.link == cell.product?.productImage})
{cell.pImage?.image = imageAndLink.image}
else{ cell.pImage.image = UIImage(named: "placeholder")
getImage(link: cell.product?.productImage ?? "", completion: {(newImage) in
DispatchQueue.main.async {
if self.productsImages.first(where: { $0.link == newImage.link}) == nil
{
self.productsImages.append(ProductImage(link : newImage.link , image : newImage.image) )
}
if cell.product?.productImage == newImage.link{
cell.pImage.image = newImage.image
}
}
})
}
}
Thank you very much
– Акарыс Турганбекулы
Nov 22 '18 at 14:03
add a comment |
You can get the base data at first and after that get every image with single request
get base data with this code :
func POSTWithLoad(urlString: String,paramaters: [String: AnyObject]? = nil,success:@escaping (_ responseObject: AnyObject?) -> Void ,failure: @escaping (_ error: String?) -> Void ) {
Alamofire.request(baseUrlDev+urlString, method: .post, parameters:paramaters, encoding: URLEncoding.default, headers: headers).responseJSON(completionHandler: { (responseData) in
if (responseData.result.error == nil && responseData.result.isSuccess == true) {
//success
success(responseData)
} else {
//fauiler
failure("UnKnowen Data")
}
})
}
and use this for getImage :
func getImage(link : String , completion : @escaping (_ imageWithLink : (link : String,image : UIImage)) -> Void){
var image = UIImage(named: "placeholder")
URLSession.shared.dataTask(with: NSURL(string: link.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!)! as URL, completionHandler: { (data, response, error) -> Void in
if error != nil {
print("errorLoadIamge : "+link)
//completion(image)
print(error)
return
}
DispatchQueue.main.async(execute: { () -> Void in
let mimage = UIImage(data: data!)
if(mimage != nil){
image = mimage!
completion((link : link , image : image))
print("successLoadIamge : "+link)
return
}
})
}).resume()
}
then can use it in your ViewContoller like this :
let products : [Product] =
let productImages : [String] =
POSTWithLoad(urlString: "YApiLink" , paramaters: requestParameters as [String : AnyObject]?, success: { (successObject) in
products = Mapper<Product>().mapArray(JSONObject : successObject)
productsImages =
print(successObject)
}, failure :{ (failureObject) in
print(failureObject)
}
)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let product = products[indexPath.row]
let cell = YourTableView.dequeueReusableCell(withIdentifier: "CellIdentifier", for: indexPath) as! YourTableViewCell
if let imageAndLink = productsImages.first(where: { $0.link == cell.product?.productImage})
{cell.pImage?.image = imageAndLink.image}
else{ cell.pImage.image = UIImage(named: "placeholder")
getImage(link: cell.product?.productImage ?? "", completion: {(newImage) in
DispatchQueue.main.async {
if self.productsImages.first(where: { $0.link == newImage.link}) == nil
{
self.productsImages.append(ProductImage(link : newImage.link , image : newImage.image) )
}
if cell.product?.productImage == newImage.link{
cell.pImage.image = newImage.image
}
}
})
}
}
You can get the base data at first and after that get every image with single request
get base data with this code :
func POSTWithLoad(urlString: String,paramaters: [String: AnyObject]? = nil,success:@escaping (_ responseObject: AnyObject?) -> Void ,failure: @escaping (_ error: String?) -> Void ) {
Alamofire.request(baseUrlDev+urlString, method: .post, parameters:paramaters, encoding: URLEncoding.default, headers: headers).responseJSON(completionHandler: { (responseData) in
if (responseData.result.error == nil && responseData.result.isSuccess == true) {
//success
success(responseData)
} else {
//fauiler
failure("UnKnowen Data")
}
})
}
and use this for getImage :
func getImage(link : String , completion : @escaping (_ imageWithLink : (link : String,image : UIImage)) -> Void){
var image = UIImage(named: "placeholder")
URLSession.shared.dataTask(with: NSURL(string: link.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!)! as URL, completionHandler: { (data, response, error) -> Void in
if error != nil {
print("errorLoadIamge : "+link)
//completion(image)
print(error)
return
}
DispatchQueue.main.async(execute: { () -> Void in
let mimage = UIImage(data: data!)
if(mimage != nil){
image = mimage!
completion((link : link , image : image))
print("successLoadIamge : "+link)
return
}
})
}).resume()
}
then can use it in your ViewContoller like this :
let products : [Product] =
let productImages : [String] =
POSTWithLoad(urlString: "YApiLink" , paramaters: requestParameters as [String : AnyObject]?, success: { (successObject) in
products = Mapper<Product>().mapArray(JSONObject : successObject)
productsImages =
print(successObject)
}, failure :{ (failureObject) in
print(failureObject)
}
)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let product = products[indexPath.row]
let cell = YourTableView.dequeueReusableCell(withIdentifier: "CellIdentifier", for: indexPath) as! YourTableViewCell
if let imageAndLink = productsImages.first(where: { $0.link == cell.product?.productImage})
{cell.pImage?.image = imageAndLink.image}
else{ cell.pImage.image = UIImage(named: "placeholder")
getImage(link: cell.product?.productImage ?? "", completion: {(newImage) in
DispatchQueue.main.async {
if self.productsImages.first(where: { $0.link == newImage.link}) == nil
{
self.productsImages.append(ProductImage(link : newImage.link , image : newImage.image) )
}
if cell.product?.productImage == newImage.link{
cell.pImage.image = newImage.image
}
}
})
}
}
answered Nov 21 '18 at 22:31
AmmarAmmar
192110
192110
Thank you very much
– Акарыс Турганбекулы
Nov 22 '18 at 14:03
add a comment |
Thank you very much
– Акарыс Турганбекулы
Nov 22 '18 at 14:03
Thank you very much
– Акарыс Турганбекулы
Nov 22 '18 at 14:03
Thank you very much
– Акарыс Турганбекулы
Nov 22 '18 at 14:03
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420432%2falamofire-general-request%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
"Is it possible to pull simple data like" - Yes, anything a HTTP server can produce, you can consume - which raises the questions over, what is the server responding with? You seem to trying to parse some JSON, is the server returning a JSON response? You question is to general and doesn't point to a specific problem or issue. Were you using a previous approach (
URLSession
?) which was working and this isn't? What URL are you communicating with? What are the inputs and expected outputs? Are you having trouble parsing the result or populating the table?– MadProgrammer
Nov 21 '18 at 21:06
Oh no, I don't have problem with populating data. I just wanted to write 1 Alamofire request for simple objects and image data as well
– Акарыс Турганбекулы
Nov 21 '18 at 21:08
So you have, two requests to make that return different data sets and you want to some how combine them?
– MadProgrammer
Nov 21 '18 at 21:10
Yes, something like Alamofire.request(baseURL).response { (response, error, data) in
– Акарыс Турганбекулы
Nov 21 '18 at 21:12
This might be beyond the scope of your intention, but I'd consider looking something like "PromiseKit" or "Hydra", which would manage the execution of two async operations and a much more elegant way, other then using a bunch of semaphores and other locking/notification mechanisms ... just saying
– MadProgrammer
Nov 21 '18 at 21:14