Swift Multi Selection TableView occurs error while unselecting rowsChange second table content based on first table row selected in swiftHow to detect tableView cell touched or clicked in swiftSending data to a new view controller through didselectrowatindexpathUpdate or reload UITableView after completion of delete action on detail viewthread 1: exc_bad_instruction(code=exc_1386_invop,subcode=0x0)How do I make my table view's cell selection based on a stepper value, not the physical selection of the cell in swift 3?Make (first) row unselectable in pickerview (Swift 3, Xcode)How Can I Fetch Sub Category From Rest Api(Restkit) Using Expandable Tableview Cell Swift 3How to implement one select/deselect all button while above tableview in objective c?Cannot assign value of type 'String?' to type 'CBPeripheral?'
xcolor breaking ligatures
Why does Bran want to find Drogon?
Dad jokes are fun
What does it mean when a vocal teacher tell you that your lowest notes are heavy?
One word for 'the thing that attracts me'?
Variable declaraton with extra in C
Does French have the English "short i" vowel?
Expected maximum number of unpaired socks
Why is the Eisenstein ideal paper so great?
Why does the hash of infinity have the digits of π?
What weight should be given to writers groups critiques?
What is the recommended procedure to land a taildragger in a crosswind?
...And they were stumped for a long time
Apart from the sine wave, are there any other waveshapes that could be thought of as commonly appearing "in nature"?
How to keep consistency across the application architecture as a team grows?
Is this homebrew "Cactus Grenade" cantrip balanced?
Can we assume that a hash function with high collision resistance also means highly uniform distribution?
Why did Jon Snow admit his fault in S08E06?
Why does the Starter Set wizard have six spells in their spellbook?
How to let other coworkers know that I don't share my coworker's political views?
Why sampling a periodic signal doesn't yield a periodic discrete signal?
Testing using real data of the customer
Can a UK national work as a paid shop assistant in the USA?
Why was this character made Grand Maester?
Swift Multi Selection TableView occurs error while unselecting rows
Change second table content based on first table row selected in swiftHow to detect tableView cell touched or clicked in swiftSending data to a new view controller through didselectrowatindexpathUpdate or reload UITableView after completion of delete action on detail viewthread 1: exc_bad_instruction(code=exc_1386_invop,subcode=0x0)How do I make my table view's cell selection based on a stepper value, not the physical selection of the cell in swift 3?Make (first) row unselectable in pickerview (Swift 3, Xcode)How Can I Fetch Sub Category From Rest Api(Restkit) Using Expandable Tableview Cell Swift 3How to implement one select/deselect all button while above tableview in objective c?Cannot assign value of type 'String?' to type 'CBPeripheral?'
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
i have a problem with my multi selection table view. I receive an error if i unselect the previous select rows with an different order than i have selected it. It says
Index out of range
I receive this error while i'm trying to remove an item of my array. Here is my Code:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
if tableView.cellForRow(at: indexPath)?.accessoryType == UITableViewCell.AccessoryType.checkmark
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCell.AccessoryType.none
//Line above occurs the error
checkedCategories.remove(at: indexPath.row)
else
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCell.AccessoryType.checkmark
checkedCategories.append(allcategories[indexPath.row])
ios swift
add a comment |
i have a problem with my multi selection table view. I receive an error if i unselect the previous select rows with an different order than i have selected it. It says
Index out of range
I receive this error while i'm trying to remove an item of my array. Here is my Code:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
if tableView.cellForRow(at: indexPath)?.accessoryType == UITableViewCell.AccessoryType.checkmark
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCell.AccessoryType.none
//Line above occurs the error
checkedCategories.remove(at: indexPath.row)
else
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCell.AccessoryType.checkmark
checkedCategories.append(allcategories[indexPath.row])
ios swift
Show declaration ofcheckedCategories
. Is it set or array?
– ManWithBear
Mar 23 at 23:44
yes, it is a Array[Object]
– Markus Gerlach
Mar 24 at 8:38
add a comment |
i have a problem with my multi selection table view. I receive an error if i unselect the previous select rows with an different order than i have selected it. It says
Index out of range
I receive this error while i'm trying to remove an item of my array. Here is my Code:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
if tableView.cellForRow(at: indexPath)?.accessoryType == UITableViewCell.AccessoryType.checkmark
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCell.AccessoryType.none
//Line above occurs the error
checkedCategories.remove(at: indexPath.row)
else
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCell.AccessoryType.checkmark
checkedCategories.append(allcategories[indexPath.row])
ios swift
i have a problem with my multi selection table view. I receive an error if i unselect the previous select rows with an different order than i have selected it. It says
Index out of range
I receive this error while i'm trying to remove an item of my array. Here is my Code:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
if tableView.cellForRow(at: indexPath)?.accessoryType == UITableViewCell.AccessoryType.checkmark
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCell.AccessoryType.none
//Line above occurs the error
checkedCategories.remove(at: indexPath.row)
else
tableView.cellForRow(at: indexPath)?.accessoryType = UITableViewCell.AccessoryType.checkmark
checkedCategories.append(allcategories[indexPath.row])
ios swift
ios swift
asked Mar 23 at 23:33
Markus GerlachMarkus Gerlach
365
365
Show declaration ofcheckedCategories
. Is it set or array?
– ManWithBear
Mar 23 at 23:44
yes, it is a Array[Object]
– Markus Gerlach
Mar 24 at 8:38
add a comment |
Show declaration ofcheckedCategories
. Is it set or array?
– ManWithBear
Mar 23 at 23:44
yes, it is a Array[Object]
– Markus Gerlach
Mar 24 at 8:38
Show declaration of
checkedCategories
. Is it set or array?– ManWithBear
Mar 23 at 23:44
Show declaration of
checkedCategories
. Is it set or array?– ManWithBear
Mar 23 at 23:44
yes, it is a Array[Object]
– Markus Gerlach
Mar 24 at 8:38
yes, it is a Array[Object]
– Markus Gerlach
Mar 24 at 8:38
add a comment |
1 Answer
1
active
oldest
votes
You always adding items in the end of array (so index of added item is checkedCategories.count - 1
). But deleting by index of row.
So instead of row index, get index of added category and then remove by this index
if let index = checkedCategories.firstIndex(of: allcategories[indexPath.row])
checkedCategories.remove(at: index)
Hey, i cannot use this code, xcode is throwing different errors.
– Markus Gerlach
Mar 24 at 8:39
Maybe its because it is checkedCategories is [SellerObject]
– Markus Gerlach
Mar 24 at 9:10
@MarkusGerlach perhaps you could share what errors it throwing?
– ManWithBear
Mar 24 at 11:06
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%2f55319354%2fswift-multi-selection-tableview-occurs-error-while-unselecting-rows%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 always adding items in the end of array (so index of added item is checkedCategories.count - 1
). But deleting by index of row.
So instead of row index, get index of added category and then remove by this index
if let index = checkedCategories.firstIndex(of: allcategories[indexPath.row])
checkedCategories.remove(at: index)
Hey, i cannot use this code, xcode is throwing different errors.
– Markus Gerlach
Mar 24 at 8:39
Maybe its because it is checkedCategories is [SellerObject]
– Markus Gerlach
Mar 24 at 9:10
@MarkusGerlach perhaps you could share what errors it throwing?
– ManWithBear
Mar 24 at 11:06
add a comment |
You always adding items in the end of array (so index of added item is checkedCategories.count - 1
). But deleting by index of row.
So instead of row index, get index of added category and then remove by this index
if let index = checkedCategories.firstIndex(of: allcategories[indexPath.row])
checkedCategories.remove(at: index)
Hey, i cannot use this code, xcode is throwing different errors.
– Markus Gerlach
Mar 24 at 8:39
Maybe its because it is checkedCategories is [SellerObject]
– Markus Gerlach
Mar 24 at 9:10
@MarkusGerlach perhaps you could share what errors it throwing?
– ManWithBear
Mar 24 at 11:06
add a comment |
You always adding items in the end of array (so index of added item is checkedCategories.count - 1
). But deleting by index of row.
So instead of row index, get index of added category and then remove by this index
if let index = checkedCategories.firstIndex(of: allcategories[indexPath.row])
checkedCategories.remove(at: index)
You always adding items in the end of array (so index of added item is checkedCategories.count - 1
). But deleting by index of row.
So instead of row index, get index of added category and then remove by this index
if let index = checkedCategories.firstIndex(of: allcategories[indexPath.row])
checkedCategories.remove(at: index)
answered Mar 23 at 23:49
ManWithBearManWithBear
1,854720
1,854720
Hey, i cannot use this code, xcode is throwing different errors.
– Markus Gerlach
Mar 24 at 8:39
Maybe its because it is checkedCategories is [SellerObject]
– Markus Gerlach
Mar 24 at 9:10
@MarkusGerlach perhaps you could share what errors it throwing?
– ManWithBear
Mar 24 at 11:06
add a comment |
Hey, i cannot use this code, xcode is throwing different errors.
– Markus Gerlach
Mar 24 at 8:39
Maybe its because it is checkedCategories is [SellerObject]
– Markus Gerlach
Mar 24 at 9:10
@MarkusGerlach perhaps you could share what errors it throwing?
– ManWithBear
Mar 24 at 11:06
Hey, i cannot use this code, xcode is throwing different errors.
– Markus Gerlach
Mar 24 at 8:39
Hey, i cannot use this code, xcode is throwing different errors.
– Markus Gerlach
Mar 24 at 8:39
Maybe its because it is checkedCategories is [SellerObject]
– Markus Gerlach
Mar 24 at 9:10
Maybe its because it is checkedCategories is [SellerObject]
– Markus Gerlach
Mar 24 at 9:10
@MarkusGerlach perhaps you could share what errors it throwing?
– ManWithBear
Mar 24 at 11:06
@MarkusGerlach perhaps you could share what errors it throwing?
– ManWithBear
Mar 24 at 11:06
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%2f55319354%2fswift-multi-selection-tableview-occurs-error-while-unselecting-rows%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
Show declaration of
checkedCategories
. Is it set or array?– ManWithBear
Mar 23 at 23:44
yes, it is a Array[Object]
– Markus Gerlach
Mar 24 at 8:38