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;








-2















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])











share|improve this question






















  • 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

















-2















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])











share|improve this question






















  • 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













-2












-2








-2








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])











share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 23 at 23:33









Markus GerlachMarkus Gerlach

365




365












  • 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

















  • 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
















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












1 Answer
1






active

oldest

votes


















0














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)






share|improve this answer























  • 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











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
);



);













draft saved

draft discarded


















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









0














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)






share|improve this answer























  • 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















0














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)






share|improve this answer























  • 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













0












0








0







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)






share|improve this answer













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)







share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현