Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-16-2011, 11:12 AM   #1 (permalink)
iAS
Registered Member
 
Join Date: Jul 2011
Posts: 15
iAS is on a distinguished road
Post Delete the Cell from UITableView

The UITableView is Populated using the NSMutuableArray.

I had displayed values from NSArray into the UITableViewCell,

What i need is delete the individual cell from TableView, for this i need to delete particular element from nsArray using [<arrayname> removeObjectAtIndex: indexPath.row];
and then reload the tableview.

What else i am suppose to do, Do i need to write any tableView Delegate Methods.
iAS is offline   Reply With Quote
Old 08-16-2011, 11:21 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 97
Bopols is on a distinguished road
Default

you just need to delete the object from the array and then call [tableview reloadData]

oh btw, you should use NSMutableArray
Bopols is offline   Reply With Quote
Old 08-16-2011, 09:56 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 27
rappa819 is on a distinguished road
Default

Is your array stored somewhere like in a plist? Because if your declaring it on viewDidLoad with all its objects and remove one during runtime, the next time your app loads it will be back. I suggest if you want to populate a table view with array data and be able to delete, then save a NSArray to NSUserDefaults and use setObject, and removeObjectAtIndex.

But that just my 2 cents.
rappa819 is offline   Reply With Quote
Old 08-16-2011, 10:25 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Quote:
Originally Posted by Bopols View Post
you just need to delete the object from the array and then call [tableview reloadData]
If you want a nice animation, this is not the correct approach.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 08-17-2011, 07:46 AM   #5 (permalink)
iAS
Registered Member
 
Join Date: Jul 2011
Posts: 15
iAS is on a distinguished road
Post

I have the UITableView Working to delete the values from NSMutableArray A and the reload the UItableView.

But, Now i have to update the plist by updated NSMutableArray.

Let the Custom Object be z
z { fname, lastname, address }

My NSMutableArray A consists of Custom Object z not Just One Element in the NSMutableArray

Now due to custom object i am unable to use writeTofile in plist with updated NSMutableArray.

could someone suggest something on the issue

Thankx for any reply.
iAS is offline   Reply With Quote
Old 08-17-2011, 10:46 AM   #6 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 4
the_magic_man is on a distinguished road
Default

I'm not 100% sure I understand the problem you're having, but are you using the TableViewDataSource protocol? If you are, and you're implementing

tableView:commitEditingStyle:forRowAtIndexPath:

then you should be able to handle changing the data source and animating the deletion of the row in one stroke. That method is called when the tableview is sent an "insert" or "delete" message and is basically there to allow the TableViewDataSource to make changes to match the view's content.

Also, are you using Core Data to model your content? it seems like persisting your data in a relational model instead of custom objects might be easier. That way each array is only holding an fundamental object (NSString, int, BOOL), and that's all tied together at runtime
the_magic_man is offline   Reply With Quote
Old 08-17-2011, 11:42 AM   #7 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 97
Bopols is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
If you want a nice animation, this is not the correct approach.
so what's the correct one? I might use that instead so the user will at least know that the cell is being deleted by fading out the cell or something.

thanks

Last edited by Bopols; 08-17-2011 at 11:44 AM.
Bopols is offline   Reply With Quote
Old 08-17-2011, 11:45 AM   #8 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Quote:
Originally Posted by Bopols View Post
so what's the correct one? I might use that instead so the user will at least know that the cell is being deleted by fading out the cell or something.
Insert or delete rows. Reloading the whole table is brute force. See the overview presentation in the table view link in my signature. I really need to get the next blog post written.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 08-17-2011, 02:40 PM   #9 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 4
the_magic_man is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Insert or delete rows. Reloading the whole table is brute force. See the overview presentation in the table view link in my signature. I really need to get the next blog post written.
good series so far
the_magic_man is offline   Reply With Quote
Reply

Bookmarks

Tags
nsmutablearray, uitableview, uitableview cell

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 393
13 members and 380 guests
7twenty7, chiataytuday, cristofercolmbos, dedeys78, fiftysixty, gmarro, jimmyon122, jonathandeknudt, pungs, raymng, stanny, tymex, UMAD
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:08 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0