Couchbase iOS: cellforRowatIndex not firing and custom cell not appearing

46 views
Skip to first unread message

Souhail Marghabi

unread,
Mar 30, 2015, 12:40:18 PM3/30/15
to mobile-c...@googlegroups.com
Hello,

I have been facing this weird issue with CBLUITableSource. The cellforRow does not launch and my custom cells is not launched (even though other calls like updateFromQuery do fire)  when view is loaded.

I have a custom cell xib and a xib with a tableview.(i hooked the table source object to the tableview as seen on examples such as todolite, omoidebase. 

in my viewdidload : 

[self.tableView registerNib:[UINib nibWithNibName:@"DRContactsTableViewCell" bundle:nil] forCellReuseIdentifier:@"contactCell"];

 CBLQuery *query = [DRContacts queryContactsBy:self.currentOfferID error:&error];

    

    if (_dataSource) {

        _dataSource.query = query.asLiveQuery;

       // _dataSource.tableView = self.contactsTableView;

    }


it does not go here when I check on breakpoints:

- (UITableViewCell *)couchTableSource:(CBLUITableSource *)source cellForRowAtIndexPath:(NSIndexPath *)indexPath {


    DRContactsTableViewCell *cell = (DRContactsTableViewCell *)[source.tableView

                                                    dequeueReusableCellWithIdentifier:CellIdentifier

                                                    forIndexPath:indexPath];

    CBLQueryRow *row = [source rowAtIndex:indexPath.row];

    DRContacts *contactCell = [DRContacts modelForDocument:row.document];

    cell.contactName.text = contactCell.nom;

    return cell;

}


a screenshot below for the xib outlets.



Can anyone please help.

Jens Alfke

unread,
Mar 30, 2015, 12:59:00 PM3/30/15
to mobile-c...@googlegroups.com
The screenshot didn’t appear.

Best advice I can give is to check that all the outlets are non-nil at runtime. Either set a breakpoint and look at variables, or add NSAssert calls. Usually this kind of problem is because you forgot to wire something up and its value is nil (remember that calling a method on nil is not an error in Obj-C, just a no-op.)

—Jens

Souhail Marghabi

unread,
Mar 31, 2015, 4:11:06 AM3/31/15
to mobile-c...@googlegroups.com
Hello,

I have uploaded the screenshot again.  I have the outlets linked as in the sample apps iOS. datasource for uitableview is linked to the cbltablesource object. I am not sure what the source of the problem here is.

In my uiviewcontroller in the viewdidload i made sure to have this: @interface DRContactListViewController : UIViewController<CBLUITableDelegate,UITextFieldDelegate>

 //associate with table cell Xib

  [self.tableView registerNib:[UINib nibWithNibName:@"DRContactsTableViewCell" bundle:nil] forCellReuseIdentifier:@"contactCell"];

    

    CBLQuery *query = [DRContacts queryContactsBy:self.currentOfferID error:&error];

    

    if (_dataSource) {

        _dataSource.query = query.asLiveQuery;

        _dataSource.tableView = self.tableView;

  

    }





--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/nODTLsaMRfY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/475988AD-171B-476E-911A-753824BF330A%40mooseyard.com.
For more options, visit https://groups.google.com/d/optout.

Sans titre.png

Jens Alfke

unread,
Mar 31, 2015, 11:43:16 AM3/31/15
to mobile-c...@googlegroups.com
Everything shown in the screenshot looks OK, assuming that the xib’s owner is your view controller.
Did you set breakpoints and look at the values of variables at runtime, as I suggested?

—Jens
Reply all
Reply to author
Forward
0 new messages