Swift UITableView - Insert and Delete Rows - Tutorial

Swift UITableView - Insert and Delete Rows - Tutorial

Sean Allen

7 лет назад

43,706 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

epicmc1000
epicmc1000 - 15.09.2020 06:39

I don’t understand what that random “VideoCell” type that comes after as! In the cellForRow, it fucks the entire code up!?

Ответить
MrRooney182
MrRooney182 - 18.03.2020 13:58

Clean code + great explanation = Amazing Tutorial


and also providing source code


Thank you dude, you are awesome.

Ответить
Seng Keat
Seng Keat - 29.01.2020 19:27

I loved your vids
Can you make a vid of insert data from TextField into the array pls?

Ответить
23號ASMR重度患者
23號ASMR重度患者 - 16.01.2020 06:33

How to one button delete all rows?

Ответить
تطبيقات العرب
تطبيقات العرب - 04.01.2020 22:15

Thanks Sean for the helpful video. Does data inserted to the table using this method persist? If so where is it stores? If not, how can we save the data permanently at the user device?

Ответить
Sreedhar Lakshman
Sreedhar Lakshman - 23.11.2019 10:11

Wow I understands it very easily bro u nailed it ,can u make a video to add and delete from different sections like if I tap on whatsapp status from recent it is adding to viewed after watched that like this pls .thanku

Ответить
SparkGripRacer
SparkGripRacer - 30.09.2019 17:35

@Sean could you please do a updating video cause of Apple's Documentation notice:
    // Allows multiple insert/delete/reload/move calls to be animated simultaneously. Nestable.
    @available(iOS 11.0, *)
    open func performBatchUpdates(_ updates: (() -> Void)?, completion: ((Bool) -> Void)? = nil

    // Use -performBatchUpdates:completion: instead of these methods below, which will be deprecated in a future release.
    open func beginUpdates(), ....

Ответить
Abdullah Jirjees - Computer Vision & AI
Abdullah Jirjees - Computer Vision & AI - 24.09.2019 16:47

Hello What I am doing is select date + insert data into text field then press submit to be pushed into TableViewController to display in TableViewCell in Labels, the issue is I cannot figure out how to do that, so every time you pick the date and the data and press submit it must sort in the tableviewcontroller in new tableviewcell.

Ответить
Sachin Kumar
Sachin Kumar - 18.09.2019 08:45

Hey Sean
I have a doubt what if we initially don't have any data in our array then will this work or is there anything else that we have to do..
Thanks in advance

Ответить
Sebastien Desemberg
Sebastien Desemberg - 12.09.2019 15:56

Once again, great help

Ответить
sai krishna
sai krishna - 05.09.2019 17:52

How to insert a row if I click on button directly to the tableview without any Textfield ?? Sir

Ответить
Josh Poe
Josh Poe - 18.08.2019 08:52

when the like button isn't an option - thanks for the video

Ответить
Nilesh Darji
Nilesh Darji - 30.07.2019 20:15

Hi Sean. Will this persist the addition or deletion of the row. Or do I need to implement CoreData to persist the updated tableview.

Ответить
shiv lall
shiv lall - 15.07.2019 04:50

hey, I'm new at coding and I was wondering is it consider plagiarism if I enter that deleted line of code into an app that I want to build?

Ответить
Между строк
Между строк - 30.05.2019 09:54

thank you

Ответить
Tan Alex
Tan Alex - 09.05.2019 15:06

Excuse me, where can I see your source codes. I just a beginner.

Ответить
Tan Alex
Tan Alex - 09.05.2019 14:51

So what about the content of VideoCell.swift???

Ответить
Kan
Kan - 22.04.2019 02:34

(Insert Comment Here)

Ответить
Enric Teller
Enric Teller - 04.03.2019 09:54

Excellent! Thanks.

Ответить
w6w6d
w6w6d - 06.12.2018 21:52

What if you have the button INSIDE the cell. Would you need a delegate to use the textfield text in the button function (as the textfield is registered in the VC not in the cell) ? How would the button know what do you enter in the textfield ?

Ответить
Naeem O(n)
Naeem O(n) - 14.11.2018 13:24

Are you using two separate View controllers. if yes then how are they connected to each other.

Ответить
Naeem O(n)
Naeem O(n) - 13.11.2018 20:02

hi there, what does " let cell = tableView.dequeueReusableCell(withIdentifier: "VideoCell") as! VideoCell " mean
I am using the same code just changing the "VideoCell" with "ItemCell" at both places. I am getting a error saying "Use of undeclared type 'ItemCell' ".
please help. Thank you.

Ответить
Student Programmer
Student Programmer - 29.10.2018 09:34

Beautiful tutorial Sean. just to point out am not sure if its an update in swift it self or not but the tableview.beginUpdates() code instead runs error: stating Out of index. but tableview.reloadData() work instead. 🙏🏿 keep it up Sean Allen.

Ответить
Pavel Dubinin
Pavel Dubinin - 23.10.2018 18:45

Thanks for another great video, Sean. I have an issue with making it work though, if you delete several rows one after another it crashes with "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No occurrence for index path (null)'", googling shows that that's an issue on latest iOS, but I could not find a solution. Maybe you have some thoughts?

Ответить
Dave Glassco
Dave Glassco - 17.10.2018 19:00

Once again you have you have clearly explained something I needed for a production app. Thank you.

Ответить
TinkerB
TinkerB - 19.08.2018 21:13

How about swiping the row and having 2 options like "yes" or "no"?

Ответить
LORD NIGHTSHIELD
LORD NIGHTSHIELD - 04.07.2018 17:37

Sean why not to teach on Udemy? I personally would by your course.

Ответить
ACBYTES
ACBYTES - 12.06.2018 11:53

Could you also make a video about a download manager that downloads files from Internet and write them to the device for future uses?

Ответить
ACBYTES
ACBYTES - 10.06.2018 22:55

Hi. Very helpful video but, on tableview.insertRows I get signal SIGABRT error. What should I do?

Ответить
Go Fudge Yourselves
Go Fudge Yourselves - 02.06.2018 21:18

I have one doubt, you wrote the following code
let indexPath = IndexPath(row: videos.count - 1, section: 0)

tableView.beginUpdates()
tableView.insertRows(at: [indexPath], with: .automatic)
tableView.endUpdates()

in insertNewVideoTitle(), but you can replace it with just one line
tableView.reloadData()
Same thing in editing style of table view method.

Am I missing some point?

Ответить
Saad Sikandar
Saad Sikandar - 16.05.2018 18:04

Hi Allen, how can we add the data to tableview and pass it to the next screen (segue).
Thanks a lot :)

Ответить
Subba Reddy
Subba Reddy - 03.05.2018 21:11

Hi Sean,nice videos Can you do a video best way of calling web API in swift

Ответить
Jason Chalkley
Jason Chalkley - 13.04.2018 10:45

Simple and clean, great video mate

Ответить
Thomas Tseng
Thomas Tseng - 24.02.2018 16:47

Thank you, it's a great video! But in InsertRow(tableview.insertRows(at: [IndexPath(row: videolist.count - 1, section:0)], with: .automatic)) it crashed, leaving an error 'attempt to insert row 1 into section 0, but there are only 0 rows in section 0 after the update'. How could I fix it?

Ответить
zain developer
zain developer - 16.02.2018 14:12

When (editingStyle == .insert) will run???

func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
print("this is a ttetetetette")
timeLogs.remove(at: indexPath.row)
timeLogTable.beginUpdates()
timeLogTable.deleteRows(at: [indexPath], with: .automatic)
timeLogTable.endUpdates()
}
else if editingStyle == .insert
{

print("this is a i🤡")


}
}

Ответить
Carter Cobb
Carter Cobb - 10.01.2018 15:21

Sean, I have a quick question. Do you know how to save the TableView data when the app is closed. I got my app to add and delete rows but, when I close the app the added rows are deleted. I've spent a lot of time scavenging the internet for an answer and I have not solved the problem. Could you possibly do a video on how to save the added cells? Thanks!

Ответить
Carter Cobb
Carter Cobb - 06.01.2018 04:04

Please help. When the "add" button is clicked i get an error that says "0_pthread_kill". I compared your source code to my code and it is the same. I looked up the problem and people were saying its something with breakpoints but i can't figure out what to do.

Ответить
D Chu
D Chu - 28.12.2017 03:15

Good training. Thank you Sean to make effort offering the video. One minor thing about the func insertNewVideoTitle(). Should this one be private?

Ответить
Lelvl8
Lelvl8 - 24.11.2017 13:04

PLS HELP ME , INSERTROW IS ONLY CRASHING

Ответить
steven Gao
steven Gao - 12.10.2017 09:37

will the slide to right delete method work on Firebase based table view data ? tried many times give me error. anyone got luck?

Ответить
NaturalBornSkeptic
NaturalBornSkeptic - 05.10.2017 17:23

Great tutorial.  Love the tip about keeping code clean and easy to read.  Thanks.

Ответить
Tyler
Tyler - 01.10.2017 16:53

Thanks! I'd like to see this for adding a new row dynamically to a 2D array. For example, how to get an index path in the insertNewVideoTitle() when you're working with multiple sections.

Ответить
Andy Taylor
Andy Taylor - 25.07.2017 01:20

You need to teach or a course or something! Make it look so simple!

Ответить
Jose Sanchez-Miranda Ros
Jose Sanchez-Miranda Ros - 06.07.2017 07:26

Wouldn't tapping on the add button with no text entered crash your app since you are force unwrapping the addVideoTextField.text! ?

Love your videos! I am learning from you and from the Big Nerd Ranch iOS programming book. Highly recommended!

Ответить
PeedeeThePro
PeedeeThePro - 01.07.2017 19:30

Thanks for Tutorial
Can you please let me know how to add data on tableView when textfield is in different viewController ?

Ответить