My Custom View Cell looks like the following http://img34.imageshack.us/i/screenshot20110210at627.png/
#interface AddSiteAddressCell : UITableViewCell {
IBOutlet UITextField *street;
IBOutlet UITextField *city;
IBOutlet UITextField *province;
IBOutlet UITextField *postal;
IBOutlet UITextField *country;
IBOutlet UITextField *siteName;
}
#property (nonatomic,retain)UITextField *siteName;
#end
#implementation AddSiteAddressCell
- (void) textFieldDidEndEditing:(UITextField *)textField {
NSLog(#"%#",street);
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code.
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state.
}
- (void)dealloc {
[super dealloc];
}
#end
AddSiteViewController.m
-
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.section == 0)
{
static NSString *MyIndentifier = #"MyIdentifier";
MyIndentifier = #"tblCellView";
//static NSString *CellIdentifier = #"Cell";
AddSiteAddressCell *cell = (AddSiteAddressCell *)[add_site dequeueReusableCellWithIdentifier:MyIndentifier];
if(cell == nil) {
[[NSBundle mainBundle] loadNibNamed:#"AddSiteAddressCell" owner:self options:nil];
cell = nameCell;
}
return cell;
}else if (indexPath.section == 1)
{
static NSString *MyIndentifier = #"MyIdentifier";
MyIndentifier = #"tblCellView";
//static NSString *CellIdentifier = #"Cell";
AddSiteAddressCell *cell = (AddSiteAddressCell *)[add_site dequeueReusableCellWithIdentifier:MyIndentifier];
if(cell == nil) {
[[NSBundle mainBundle] loadNibNamed:#"AddSiteAddressCell" owner:self options:nil];
cell = addressCell;
}
return cell;
}
/*static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...*/
return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
AddSiteAddressCell *cell = (AddSiteAddressCell *)[add_site cellForRowAtIndexPath:[indexPath row]];
self.test = cell.siteName.text;
NSLog(#"%#",self.test);
}
MY full view looks like this:
http://img29.imageshack.us/i/screenshot20110211at940.png/
This is what my View looks like. 2 sections with 1 row each and 1 custom cell each
Thats code from my CustomTableViewCell
I am wondering how I can access my text field in my table controller to save the data that is entered
when do u want to access it?
you should make property for your text field (e.g siteName), and then if you have the IndexPath of your cell, u can use:
AddSiteAddressCell *myCell=(AddSiteAddressCell *)[tableView cellForRowAtIndexPath:MyIndexPath];
myCell.siteName....
Related
Please help me with UITableViewCells.
I have followed many tutorials and sites but didn't get my problem solved.
I have tried to make a simpleCustomCells app but data are not loaded in the table view.
1.I have a table view controller:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [NSArray arrayWithArray:[[NSBundle mainBundle] loadNibNamed:#"CustomCell" owner:self options:nil]];
for(id obj in nib)
{
if([obj isKindOfClass:[UITableViewCell class]])
{
cell = (CustomCell *)obj;
}
}
}
cell.label.text = #"hello";
return cell;
}
Also tried
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"CustomCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
"within if(cell==nill)"
2.I have created CustomCell : UITableViewCell with only a UILabel outlet. Changed CustomCell.xib identifier's name.
When I run this app I get this kind of error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSObject 0x71627f0> setValue:forUndefinedKey:]: this class
is not key value coding-compliant for the key label.
Please Help me with this issue, where am I going wrong.
Ok, I think I got where you are getting stuck.
Step 1 : Disconnect the outlet UILabel from the xib file.
Step 2 : Go to your xib file and you will see your objects list on the left hand side of the xib file.
Step 3 : Take your mouse pointer just below where objects is written. You will find Custom Cell written.
Step 4 : Press ctrl and drag it to the label and now Connect the Outlet to label.
Step 5 : Clean your program and Run it again.
All the best. If you still have doubts, I will elaborate. :)
I think you should add like this, I hope it works
static NSString *CellIdentifier = #"Cell";
customcellCell *cell = (customcellCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; <- set your customclass in this line.
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"customviewcell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.label.text = #"hello";
return cell;
Use following way :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ContactListCell *contactCell;
NSString *contactCellID = [NSString stringWithFormat:#"ContactCell%d%d",indexPath.row,indexPath.section];
contactCell = (ContactListCell *)[tableView dequeueReusableCellWithIdentifier:contactCellID];
if(!contactCell) {
contactCell = [[ContactListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:contactCellID];
contactCellID = nil;
}
strName = #"First name";
contactCell.lblFirstName.text = [strName capitalizedString];
return contactCell;
}
For Custom cell .h file
#interface ContactListCell : UITableViewCell {
UILabel *lblFirstName;
}
#property (strong, nonatomic) UILabel *lblFirstName;
#end
For Custom cell .m file
#implementation ContactListCell
#synthesize lblFirstName;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
lblFirstName = [[UILabel alloc]initWithFrame:CGRectMake(kxiPadFirstNameCellLandscape, kyiPadFirstNameCellLandscape, kiPadFirstNameCellWidthLandscape, kiPadFirstNameCellHeightLandscape)];
lblFirstName.backgroundColor= [UIColor clearColor];
lblFirstName.numberOfLines = 0;
lblFirstName.textColor = kCustomCellFontColor;
[self.contentView addSubview:lblFirstName];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
#end
Why not give you're cell an identifier and instantiate it with dequewithreusableidentifier?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = #"Cell";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[AanbodTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.Label.text =#"Hello"
return cell;
}
i would also refer to this very good tutorial http://www.appcoda.com/customize-table-view-cells-for-uitableview/
I have a button in each cell in my tableview. Basically I'm saving the cell's indexPath in the button's tag in thecellForRowAtIndexPath` method like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
UIButton *expandPhoto = (UIButton *)[cell viewWithTag:101];
expandPhoto.tag = indexPath.row;
[expandPhoto addTarget:self action:#selector(expand:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
The problem is, when i scroll down the button's indexPath resets.
I've searched alot in the internet but I'm stuck with this problem for days.
You are using static NSString *CellIdentifier = #"Cell"; it will reuse the cells so you will get the cell index as 0 when it should show 6, shows 1 when it should show 7, etc..
If you want to get the index as 0,1,....6,7, etc..
Use Like this,
NSString *CellIdentifier = [NSString stringWithFormat:#"Cell%d",indexPath.row];
But it wont reuse the cell.
I solved my issue using this code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
UIButton *expandPhoto = (UIButton *)[cell viewWithTag:101];
[expandPhoto setTag:indexPath.row];
[expandPhoto addTarget:self action:#selector(expand:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
- (IBAction)expand:(id)sender {
UIButton *btn = (UIButton*) sender;
UITableViewCell *cell = (UITableViewCell*) btn.superview.superview;
NSIndexPath *indexPath = [tableView indexPathForCell:cell];
int row = indexPath.row;
}
Thanks.
Custom table view cell is the best approuch to solve this problem here we need to create different the Custom table view cell controller and use this in cellForAtIndexPath tableview Datasource :
CustomTableViewCell.h
#import <UIKit/UIKit.h>
#interface CustomTableViewCell : UITableViewCell
#property (nonatomic, readonly) UILabel *tblViewLabel;
#property (nonatomic, readonly) UIButton *tblViewBtn;
#end
CustomTableViewCell.m
#import "CustomTableViewCell.h"
#implementation CustomTableViewCell
#synthesize tblViewLabel = _tblViewLabel;
#synthesize tblViewBtn = _tblViewBtn;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString
*)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
_tblViewLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 8, 50, 30)];
[self.contentView addSubview:_tblViewLabel];
[_tblViewLabel release];
_tblViewBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
_tblViewBtn.frame = CGRectMake(100, 5, 200, 20);
[_tblViewBtn.titleLabel setText:[NSString stringWithFormat:#"%d",self.tag]];
[_tblViewBtn addTarget:self action:#selector(tblBtnPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:_tblViewBtn];
[_tblViewBtn release];
}
return self;
}
- (void)tblBtnPressed :(UIButton *)btn {
NSLog(#"Here %d button is pressed.",btn.tag);
}
- (void)dealloc {
[_tblViewLabel release];
[_tblViewBtn release];
[super dealloc];
}
#end
//------------------------//
Here In Your Previous controller's cellForRowAtIndexPath datasource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *MyIdentifier = #"MyIdentifier";
CustomTableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:MyIdentifier] ;
if (cell == nil){
cell = [[CustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:MyIdentifier];
}
cell.tblViewLabel.text =[NSString stringWithFormat:#"%d",indexPath.row];
[cell.tblViewBtn setTitle:[NSString stringWithFormat:#"%d",indexPath.row] forState:UIControlStateNormal];
cell.tblViewBtn.tag = indexPath.row;
return cell;
}
i have one view controller
Name : FirstVC
i have table view in that view controller. in my table view i load a custom cell. in my custom cell there is 1 label and 1 button. i set label as well as button of custom cell from FirstVC. See bellow code.
in FirstVC.h
#interface FirstVC : UIViewController <UITableViewDataSource, UITableViewDelegate>
{
IBOutlet UITableView *TblView;
IBOutlet CustomCell *customCell;
}
- (void)addCounter:(NSInteger)pCat_ID;
#end
in FirstVC.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = #"Cell";
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil){
[[NSBundle mainBundle] loadNibNamed:#"CustomCell_iPhone" owner:self options:nil];
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell = categoryCustomCell;
}
NSInteger pCat_id = [[[arrayCategoryData objectAtIndex:indexPath.row] objectForKey:#"cat_id"] integerValue];
[customCell setTextForLable:#"Test"];
[customCell setAddCounterButton:pCat_id];
return cell;
}
- (void)addCounter:(NSInteger)pCat_ID
{
//Some code hereā¦.
}
in CustomCell.h
#interface CustomCell : UITableViewCell
{
IBOutlet UILabel *lblCategoryName;
IBOutlet UIButton *btnAddCounter;
}
- (void)setTextForLable:(NSString *)cat_name;
- (void)setAddCounterButton:(NSInteger)cat_ID;
#end
in CustomCell.m
#implementation CustomCell
- (void)setTextForLable:(NSString *)cat_name
{
lblCategoryName.text = cat_name;
}
- (void)setAddCounterButton:(NSInteger)cat_ID
{
[btnAddCounter addTarget:self action:#selector(addCounter:cat_ID) forControlEvents:UIControlEventTouchUpInside];
}
#end
i want to call addCounter:(NSInteger)pCat_ID method from custom cell. but this idea can not worked. Please suggest me new idea.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = #"Cell";
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil){
[[NSBundle mainBundle] loadNibNamed:#"CustomCell_iPhone" owner:self options:nil];
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell = categoryCustomCell;
}
NSInteger pCat_id = [[[arrayCategoryData objectAtIndex:indexPath.row]
// call your method from here.. and put your method in this file then it will work for you
[cell.btnAddCounter addTarget:self action:#selector(addCounter:pCat_id) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
I need to pass an string value from UItable View Controller to Uitable view cell
Here is the code which i used
In my Table view controller
#import <UIKit/UIKit.h>
#import "CustomCell.h"
#interface DetViewController : UITableViewController
{
NSString *urlstring;
CustomCell *cust;
}
#property(nonatomic,retain)NSString *urlstring;
#property(nonatomic,retain)NSMutableArray *mutarray;
#property(nonatomic,retain)CustomCell *cust;
#end
and im TableViewController.m have
- (void)viewDidLoad
{
[super viewDidLoad];
url=[NSURL URLWithString:urlstring];
urldata=[[NSString alloc]initWithContentsOfURL:url];
mutarray=[[NSMutableArray alloc]init];
self.mutarray=[urldata JSONValue];
NSDictionary *dict=[mutarray objectAtIndex:0];
self.title=[dict valueForKey:#"category"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
CustomCell *cell =(CustomCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.custurlstring=urlstring;
NSLog(#"%#", cell.custurlstring);
return cell;
}
In my Custom Tableviewcell.h have
#import <UIKit/UIKit.h>
#interface CustomCell : UITableViewCell{
NSString *custurlstring;
}
#end
My custom Tableviewcell.m have
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
NSLog(#"%#",custurlstring);
}
return self;
}
Now i got the string content in tableviewcontroller by using NSLog..but if i tried to print the value in TableViewCell i cant get those values...
Guidance Please...
No need of customizing a cell for displaying a image and labels on it,
Just add them in normal cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomCell alloc] initWithStyle:<style enum value> reuseIdentifier:reuseIdentifier string:urlstring]
//cell.mystring = self.mystring;
}
// customize your image and your labels here with rects here
UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:#"yourimage.png"]];
[cell.contentView addSubview:image];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(your rect here)];
[cell.contentView addSubview:label];
return cell;
}
You need to setup your cell in cellForRowAtIndexPath: and then set the string on the cell inside this method. This method is already provided to you when you create a UITableViewController.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.custurlstring = urlstring;
return cell;
}
You should do it in delegate method - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
You can write something like that:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomCell alloc] initWithStyle:<style enum value> reuseIdentifier:reuseIdentifier string:urlstring]
//cell.mystring = self.mystring;
}
return cell;
}
Added:
You can write custom constructor and initialize the cell using it. This way NSLog will print the string as expected:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier string:(NSString *)string
{
self = [self initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.custurl=[NSURL URLWithString:string];
NSLog(#"%#",custurl);
}
return self;
}
When Ever I try to load data from an array into my table using custom cells it only shows the last cell like its overwriting all the cells until I Get to the end of the list. The table was created programmatically and when the cells don't load the blank table scrolls. If however I load the cells then only the last cell shows up and it won't scroll.
I figure I made a typo or something but I can't really see anything that would be of much help. The parser works and the array is fine its just that the cells are acting strange. I wanted to make it so that I had a fixed bar over the table as well but first I needed to get the custom cells to show up in the table and scroll properly
schedule.h
#interface Schedule : UIViewController <UITableViewDelegate, UITableViewDataSource> {
IBOutlet UITableView *newsTable;
UIActivityIndicatorView *activityIndicator;
CGSize cellSize;
NSXMLParser *fileParser;
NSMutableArray * events;
NSMutableArray * announcements;
NSMutableDictionary * item;
NSString *currentElement;
NSMutableString * currentTitle, * currentDate, * currentSummary, * currentId, * curr entTime, *currentContent;
UITableViewCell *appCell;
}
#property(nonatomic, retain)IBOutlet UITableView *newsTable;
#property(nonatomic, retain)IBOutlet UITableViewCell *appCell;
-(void)parseXMLFileAtURL:(NSString *)URL;
#end
schedule.m
- (void)loadView{
UITableView *tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]
style:UITableViewStylePlain];
tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
tableView.delegate = self;
tableView.dataSource = self;
tableView.tag = 4;
[tableView reloadData];
self.view = tableView;
[tableView release];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [events count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:#"CustomCell" owner:self options:nil];
cell = appCell;
self.appCell = nil;
}
// Configure the cell.
UILabel *label;
label = (UILabel *)[cell viewWithTag:1];
int eventIndex = [indexPath indexAtPosition: [indexPath length] - 1];
label.text = [[events objectAtIndex: eventIndex] objectForKey: #"event"];
return cell;
}
- (void)parserDidEndDocument:(NSXMLParser *)parser {
NSLog(#"webpage parsed");
NSLog(#"events array has %d items", [events count]);
newsTable = (UITableView*)[self.view viewWithTag:4];
[newsTable reloadData];
}
I added more code the problem may be somewhere else.
I think your problem is that the cell is being released. When you call self.appCell = nil;, the object will be released and the variable set to nil. Try changing cell = appCell; to cell = [[appCell retain] autorelease]; so that the cell is retained long enough for the table view to retain it again.
Also, you could change int eventIndex = [indexPath indexAtPosition: [indexPath length] - 1]; to int eventIndex = indexPath.row;. The row and section properties were added to NSIndexPath specifically for use in UITableView, and it is guaranteed that the index path passed to cellForRowAtIndexPath: will contain exactly two indices.
try with following code;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = #"CellIdentifier";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; // CustomCell is the class for standardCell
if (cell == nil)
{
NSArray *objectList = [[NSBundle mainBundle] loadNibNamed:#"CustomCell" owner:self options:nil];
for (id currentObject in objectList) {
if([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (CustomCell*)currentObject;
break;
}
}
cell.label.text = [[events objectAtIndex: indexPath.row] objectForKey: #"event"];
}
return cell;
}
when you load the xib file with NSBundle, it will return an array of Bundle. Then you have to check it and then use it.
If you tried like;
NSString *memberName; // member variable
NSString *name = memberName;
memberName = nil;
// the member variable "memberName, giving the reference to name;
//So if you set memberName as nil, name also become a nil value.
// You have to use like;
name = [memberName retain];
memberName = nil;
Try to learn more about iPhone development documents.
Click here for Documentation.
Click here for sample code.
I think it will help you.