I am new in iOS and I am facing problem regarding to set Data Model on UIlabel
I used like this code to change
In ConnectiondidFinishLoading
AuditTextBoxarray=[[NSMutableArray alloc] init];
for(int i=0;i<idarray.count;i++)
{
DataModel *model = [DataModel new];
model.AuditTextBoxString = @"";
[AuditTextBoxarray addObject:model];
}
In cellforrowatindexpath
cell.lblAuditTextBox.text=[NSString stringWithFormat:@"%@",[AuditTextBoxarray objectAtIndex:indexPath.row ]];
On Button Click
NSString *String=textView1.text;
DataModel *model = [AuditTextBoxarray objectAtIndex:index];
model.AuditTextBoxString = String;
But I am not able to set value of data model in tableview:
How can I set Data Model value to uilabel? I am doing something wrong, but what I am not getting.
DataModel.h
@interface DataModel : NSObject
@property(nonatomic, strong)NSString *strSelected;
@property(nonatomic,strong)NSString *TextViewvalue;
@property(nonatomic,strong)NSString *RateViewValue;
@property(nonatomic,strong)NSString *Popupvalue;
@property(nonatomic,strong)NSString *SurveySelected;
@property(nonatomic,strong)NSString *AuditTextBoxString;
DataModule.m
#import "DataModel.h"
@implementation DataModel
@end
I used DataModule to change Button colour and set it on the table view like this
In ConnectionDidFinishLoading
for (int i =0; i<idarray.count; i++)
{
DataModel *model = [DataModel new];
model.strSelected = @"";
[arrData addObject:model];
}
Button Click
sender.backgroundColor = [UIColor redColor];
DataModel *model = [arrData objectAtIndex:sender.tag];
model.strSelected = @"P";
cellforrowatindexoath
//background color change on button
DataModel *model = [arrData objectAtIndex:indexPath.row];
if([model.strSelected isEqualToString:@"P"])
{
cell.passbtn.backgroundColor = [UIColor redColor];
}
Now I am trying to add text on uilabel frok data model.
I just change code from
To
After you update the dataModel in ConnectiondidFinishLoading or On Button Click, Reload the tableview on main thread(if you are in a separate thread) to refresh the data on the View. something like