Get indexPath.row from tableView into cell

EDIT: Question in short: How do I access the index of the cell from the UICell class? Because atm I get it only from the method in the UITableView class which is posted beneath. end of edit

I have an iOS app and added a UITableView. I'm filling it with custom UICells and in the UITableView I use this method to delete a row and remove the objects from the datasource

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

I also added a modify-button in the UICell, so I also have to access the datasource, but I can't because it is is the UITableView class and I can't access it from the UICell class.

What is the best solution for this? Do I have to create a class for my datasource and both classes (UITableView and UICell) access it? If so, how do I do that? Sorry I am new to MVC, please help :)

Thanks in advance


You might be filling your table from an array, if this is the case, you can remove the array element at index(selected index) and reload tableview.

I think that the best way is to implement the Pattern Singleton


#import "MySingleton.h"

@implementation MySingleton
+(MySingleton *) sharedInstance{
   static  MySingleton *inst = nil;

        if (!inst) {
            inst = [[self alloc] init];
   return inst;


When I've needed to do things like that, my approach has been to use a NSNotification. The cell fires a custom notification and attaches self as the notification object. The data source listens for the notification and either handles the action itself or responds by extracting the cell object and sending whatever it needs back to it.

Need Your Help

My arguments are getting corrupted?

c++ corruption

Wow, I really have absolutely no idea what the heck is going on here. It's really boggling my mind. I have this method that I'm trying to get working (Stuff seems to randomly break without changes ...

How long does the Open Graph actions take to get approved from 'pending'?

facebook-graph-api graph action opengraph

My Facebook app has had an action pending for some time now. Does anyone know how long it typically takes to get approved for an Open Graph action? Just curious.