UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Need help with deleting and adding table view rows

Forums > iOS

I am facing difficulty in deleting and adding table view rows simultaneously and aksed a question on SO.

here is the link


Thanks for any suggestions/hints to solve this problem


We're here to help. Feel free to ask any question. But maybe your question has already been answered in @twoStraw's fabulous lessons. Are you following 100 Days of Swift or the 100 Days of SwiftUI lessons?

There are step-by-step lessons for creating arrays of data and formatting them into nice Lists and views. We can point you in the right direction, if we know where you are on your learning journey.

@twostraws gives many ideas how to create these and implement swipe to delete functions.


At the top of these web pages you'll see a search bar. I think it's on every page. Enter the phrase "swipe to delete" and press enter.

You'll see several articles and code snips related to your topic. That's your hint! Read through them, try sample code in Playgrounds, test concepts in your application, then come back here and let us know how you did. There are many folks here who will be happy to help you fill the gaps in your Swift knowledge with UIKit.


Hey, @Obelix: I think this forum would be more "welcoming" if you drop your habit of "correcting" everyone who fails to conform to your personal vision of the range of participants and questions welcome in this forum. Specifically, your declaration that "In these forums we provide assistance to HackingWithSwift students in the 100 Days of SwiftUI courses." is much narrower than the purpose of the forum defined by Paul.

This forum's home page defines its purpose as: "A welcoming place where everyone can come and ask questions, get answers, and talk about Swift."

"Everyone" includes anyone who merely wants to "talk about Swift", not just people following one of Paul's courses.

Also, Swift includes UIKit and AppKit, not just SwiftUI, and Paul has separate sub-forums for iOS and Mac. Paul's "About" post for the iOS subforum specifically recommends posting SwiftUI questions on the SwiftUI subforum, not the iOS subforum, so it's certainly inappropriate to castigate someone on the iOS forum for not using SwiftUI. If you glance at the stackoverflow thread linked by the OP, you'll see his question concerns UIKit, not SwiftUI.



You nailed it on the head. I have had nothing but issues with @obelix and had brought it to the attention of Paul @twostraws about the way he answers questions and talks to others. He seems to want everyone to conform to his way of asking a question and then makes you feel stupid for asking the question in the first place. He's very condescending and generally makes one feel like going somewhere else for help.

I'd actually left for awhile because I coudn't take it anymore. We should all be able to come here and ask questions without worrying about someone making you feel stupid for asking in the wrong place (as some are knew they might not know which forum to ask in, I've been in that situation before). We should also not have to ask our question in some sort of special way to conform to someone elses way of thinking.

We should all be able to ask questions and get help thats the point of these forums.


On 19 April, Mark aka TazmanCoder asked the forum for help on showing and dismissing action sheets. He didn't show any code. So it was hard to know what techniques he tried, what concepts he mastered and which were still forming. Knowing that information could help us focus on an answer to push him further up the ladder of SwiftUI knowledge. Yet, still he asked for help. The next day, I wrote about 25 lines of code, quite literally answering his question.

See Mark's Post

Mark postulates

We should also not have to ask our question in some sort of special way to conform to someone elses way of thinking.

I fundamentally can't see how this is a good idea. Who goes to a doctor and just describes their stuffy nose or broken ankle without letting the doctor have a look? You might even give the doctor a brief medical history to help with diagnosis. If you'd like help with your code, you might want to actually include code! To see the difference, here's a post where Felix provided code. Looking for Animation help There was no quick answer to Felix's animation question. There were some fundamental flaws in his solution. This is how I "answer questions and talk to others."

On 1 May Mark asked the forum for help with dates and time zones.

On the same day, I researched his question and provided some clarification with Playground code. I annotated the code with additional remarks to help him visualize the issue and become a better programmer. I provided links to additional, helpful resources. Mark responded:

Thanks @Obelix, ... snip ... I had read that article from Paul called Working With Date. I guess I didn't understand the whole UTC thing and that dates don't know timezones. Thanks for the code example, it made it a little more clear to me. ... snip ....

See Mark's full reply

A few days later Mark asks for opinions on "magic numbers", the practice of hard coding UI spacing, font sizes, etc. He approached the problem using enums. I offered a different opinion and approach, and provided examples. Mark replied:

@obelix, Thanks for the reply. I had a buddy mention this same thing to me. Appreciate the advice. I do see how (your advice) would make more sense. As my buddy suggested and now you suggested having meaningful names makes it much more clear what the constant is for.

See Mark's full reply

Today Mark calls me out for being rude! He says he's

had nothing but issues with Obelix

Also he says I

generally makes one feel like going somewhere else for help.

Well, isn't that a plot twist?!


Hey @bobstern! I updated my response. If I was trying to make a point, it might have been this: If we know what you've covered in the 100 Days of Swift course, we'll know how to help. Does he know about delegates? Maybe yes? Maybe no? Does he have a good handle on value types versus reference types? How might we discover this information?

If someone comes here with little or no knowledge, perhaps the forum isn't the place to get a step-by-step tutorial. @twoStraws has several great videos that might answer his very question. But if they're only on Day 12, I might not suggest extensions, closures, tuples, or custom view modifiers.

It's without irony that I notice you didn't like the hint I gave @awais to search the articles, and yet you didn't even attempt to answer his question. It probably wasn't you or Mark, but after reading my answer someone clicked the heart icon! ♥️

Did you notice that @awais posted another question a few weeks after this first post of his?
In March '22 he posted a question, and noted that he was on Day 25 of the 100 Days of the SwiftUI course! Who knows? Maybe the answers to that first post in January revealed an easier path to solving his problem? Perhaps my answer gave him a gentle push in the direction of SwiftUI. What we do know is a few weeks after I posted my response, he was on his 25th day of SwiftUI lessons. Excellent!

In my response to his March question, I gave him encouragement, and quite literally a link to the answer.

Do I dare ask? Where was your answer to his question?

And if you still think I'm missing the point, have a look at this forum thread where @rooster challenges Splinta for not providing code. Then follow the thread and review Splinta's responses.

BTW, I am looking forward to you and Mark answering questions in these forums!

Another example asking for problem or example code:
TextField Help?

Another example how to post problems: Help us help you


BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.