when parsing json table view show repeat data [closed]Parsing JSON with Unix toolsHow to parse JSON in JavaWhy can't Python parse this JSON data?Parse JSON in JavaScript?How to parse JSON using Node.js?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?How do I write JSON data to a file?Using Swift Collection Type to parse JSONParsing the JSON data with CodableUsing Codable to parse nested JSON data problem
How would one carboxylate CBG into it's acid form, CBGA?
Template code with 0xcccccccc in every ghidra decompiled function for some executables
In windows systems, is renaming files functionally similar to deleting them?
What does this Swiss black on yellow rectangular traffic sign with a symbol looking like a dart mean?
How is the idea of "girlfriend material" naturally expressed in Russian?
Basic power tool set for Home repair and simple projects
What is the highest power supply a Raspberry pi 3 B can handle without getting damaged?
Can the pre-order traversal of two different trees be the same even though they are different?
Synaptic Static - when to roll the d6?
How can the US president give an order to a civilian?
How to sort human readable size
Are there examples of rowers who also fought?
What is the name of the person who reconciled a line from Rudram to dakshinamurthy and Adi Shankaracharya?
How "fast" do astronomical events occur?
Why is Havana covered in 5-digit numbers in Our Man in Havana?
What jobs would people work in a frontier railroad town?
Why one uses 了 and the other one doesn’t?
Why things float in space, though there is always gravity of our star is present
Examples of protocols that are insecure when run concurrently
Is using legacy mode instead of UEFI mode a bad thing to do?
My student in one course asks for paid tutoring in another course. Appropriate?
Is there any way to revive my Sim?
Am I legally required to provide a (GPL licensed) source code even after a project is abandoned?
How could I create a situation in which a PC has to make a saving throw or be forced to pet a dog?
when parsing json table view show repeat data [closed]
Parsing JSON with Unix toolsHow to parse JSON in JavaWhy can't Python parse this JSON data?Parse JSON in JavaScript?How to parse JSON using Node.js?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?How do I write JSON data to a file?Using Swift Collection Type to parse JSONParsing the JSON data with CodableUsing Codable to parse nested JSON data problem
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
When I'm parsing json array in a model and append data to show in tableview it repeat's data
class ProductsModel: Codable
let id, name: String
init(id: String, name: String)
self.id = id
self.name = name
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.arr.append(ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String))
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
self.arr repeat because of for loop but when I use self.arr = [ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)]
all thing is correct but I want append data
arrays json swift
closed as off-topic by El Tomato, Cody Gray♦ Mar 25 at 7:05
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Reproducible Example." – El Tomato, Cody Gray
add a comment |
When I'm parsing json array in a model and append data to show in tableview it repeat's data
class ProductsModel: Codable
let id, name: String
init(id: String, name: String)
self.id = id
self.name = name
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.arr.append(ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String))
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
self.arr repeat because of for loop but when I use self.arr = [ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)]
all thing is correct but I want append data
arrays json swift
closed as off-topic by El Tomato, Cody Gray♦ Mar 25 at 7:05
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Reproducible Example." – El Tomato, Cody Gray
add a comment |
When I'm parsing json array in a model and append data to show in tableview it repeat's data
class ProductsModel: Codable
let id, name: String
init(id: String, name: String)
self.id = id
self.name = name
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.arr.append(ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String))
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
self.arr repeat because of for loop but when I use self.arr = [ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)]
all thing is correct but I want append data
arrays json swift
When I'm parsing json array in a model and append data to show in tableview it repeat's data
class ProductsModel: Codable
let id, name: String
init(id: String, name: String)
self.id = id
self.name = name
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.arr.append(ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String))
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
self.arr repeat because of for loop but when I use self.arr = [ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)]
all thing is correct but I want append data
arrays json swift
arrays json swift
edited Mar 25 at 6:17
Naveen Yadav
asked Mar 25 at 5:58
Naveen YadavNaveen Yadav
178
178
closed as off-topic by El Tomato, Cody Gray♦ Mar 25 at 7:05
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Reproducible Example." – El Tomato, Cody Gray
closed as off-topic by El Tomato, Cody Gray♦ Mar 25 at 7:05
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Reproducible Example." – El Tomato, Cody Gray
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Add a check while appending new product in self.arr.
Code:
var arr = [ProductsModel]()
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
let product = ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)
if let row = self.arr.index(where: $0.id == product.id)
self.arr[row] = product
else
self.arr.append(product)
self.localizationWork()
self.tblView.reloadData()
self.hideLoader()
Let me know if you are still having any issue.
add a comment |
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.arr.append(ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String))
//self.arr = [ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)]
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
} ```
add a comment |
Try this
// Put this as a property of your class
var products: [String: ProductsModel] = [:]
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.products[setFilterArray[APPKEYS.id] as! String] = ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Add a check while appending new product in self.arr.
Code:
var arr = [ProductsModel]()
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
let product = ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)
if let row = self.arr.index(where: $0.id == product.id)
self.arr[row] = product
else
self.arr.append(product)
self.localizationWork()
self.tblView.reloadData()
self.hideLoader()
Let me know if you are still having any issue.
add a comment |
Add a check while appending new product in self.arr.
Code:
var arr = [ProductsModel]()
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
let product = ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)
if let row = self.arr.index(where: $0.id == product.id)
self.arr[row] = product
else
self.arr.append(product)
self.localizationWork()
self.tblView.reloadData()
self.hideLoader()
Let me know if you are still having any issue.
add a comment |
Add a check while appending new product in self.arr.
Code:
var arr = [ProductsModel]()
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
let product = ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)
if let row = self.arr.index(where: $0.id == product.id)
self.arr[row] = product
else
self.arr.append(product)
self.localizationWork()
self.tblView.reloadData()
self.hideLoader()
Let me know if you are still having any issue.
Add a check while appending new product in self.arr.
Code:
var arr = [ProductsModel]()
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
let product = ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)
if let row = self.arr.index(where: $0.id == product.id)
self.arr[row] = product
else
self.arr.append(product)
self.localizationWork()
self.tblView.reloadData()
self.hideLoader()
Let me know if you are still having any issue.
edited Mar 25 at 6:58
answered Mar 25 at 6:10
Amir KhanAmir Khan
1,8621826
1,8621826
add a comment |
add a comment |
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.arr.append(ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String))
//self.arr = [ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)]
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
} ```
add a comment |
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.arr.append(ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String))
//self.arr = [ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)]
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
} ```
add a comment |
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.arr.append(ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String))
//self.arr = [ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)]
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
} ```
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.arr.append(ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String))
//self.arr = [ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)]
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
} ```
answered Mar 25 at 6:50
Naveen YadavNaveen Yadav
178
178
add a comment |
add a comment |
Try this
// Put this as a property of your class
var products: [String: ProductsModel] = [:]
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.products[setFilterArray[APPKEYS.id] as! String] = ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
add a comment |
Try this
// Put this as a property of your class
var products: [String: ProductsModel] = [:]
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.products[setFilterArray[APPKEYS.id] as! String] = ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
add a comment |
Try this
// Put this as a property of your class
var products: [String: ProductsModel] = [:]
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.products[setFilterArray[APPKEYS.id] as! String] = ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
Try this
// Put this as a property of your class
var products: [String: ProductsModel] = [:]
if result == "Success"
if let filterResponse = response[APPKEYS.responseData] as? [String: Any]
if let getArrayProducts = filterResponse[APPKEYS.products] as? NSArray
for filterArray in getArrayProducts
if let setFilterArray = filterArray as? [String: Any]
self.products[setFilterArray[APPKEYS.id] as! String] = ProductsModel(id: setFilterArray[APPKEYS.id] as! String, name: setFilterArray[APPKEYS.name] as! String)
self.localizationWork()
self.tblView.reloadData()
self.hideLoader();
edited Mar 25 at 9:13
answered Mar 25 at 6:52
Cerlin BossCerlin Boss
5,08411324
5,08411324
add a comment |
add a comment |