I have a UIButton
called as UploadButton
. I am using the following lines of code which takes care of the action which should happen on clicking it ::
Use the following code in cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
if( cell == nil )
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSString *key1 = [keys1 objectAtIndex:indexPath.row];
cell.textLabel.text = key1;
return cell;
}
I think this may helpful for you.
That error means that you're passing an invalid argument when you're assigning a value to keys1, self.keys1 = ...
. If you're, e.g., passing a NSMutableArray to an NSDictionary property, you'll get that error.
The problem is the following line:
self.keys1 = [NSMutableArray array];
Your UploadSpaceTableViewController
has no method setKeys / no property keys.
Edit for the 2nd error message:
UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:
This means that you should implement the UITableViewDataSource
method tableView:cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//configure your cell here
return myCongiuredTableViewCell;
}
Have you allocated your cell i think by your code it will return nill
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nill){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
NSString *key1 = [keys1 objectAtIndex:indexPath.row];
cell.textLabel.text = key1;
return cell;
}
may this will help you...