am getting the following error, cannot figure it out where it is. Please help me to find out the issue. TIA
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM length]: unrecognized selector sent to instance 0x145ecca0'
*** First throw call stack:
- (void)viewDidLoad
{
[super viewDidLoad];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont fontWithName:#"Helvetica neue" size:20.0];
//label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
//label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor]; // change this color
self.navigationItem.titleView = label;
label.text = #"My Details";
[label sizeToFit];
}
#pragma mark -
#pragma mark Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return 30;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
cell.textLabel.font=[UIFont fontWithName:#"Helvetica neue" size:14.0];
cell.detailTextLabel.font=[UIFont fontWithName:#"Helvetica neue" size:13.0];
cell.textLabel.textColor=[UIColor colorWithRed:199.0/255.0 green:65.0/255.0 blue:69.0/255.0 alpha:1.0];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
NSArray *keys = [myDict allKeys];
for(int i=0 ; i<[keys count]; i++ )
{
NSString *value=[myDict objectForKey:[keys objectAtIndex:i]];
if ([value isEqual: [NSNull null]]||[value length]==0) {
[myDict setValue:#"--" forKey:[keys objectAtIndex:i]];
}
}
if(indexPath.row==0)
{
cell.textLabel.text = #"Relationship";
cell.detailTextLabel.text=[myDict objectForKey:#"Relationship"];
}
if(indexPath.row==1)
{
cell.textLabel.text = #"Person Name";
cell.detailTextLabel.text=[myDict objectForKey:#"PersonName"];
}
if(indexPath.row==2)
{
cell.textLabel.text = #"Shopping";
cell.detailTextLabel.text=[myDict objectForKey:#"shopping"];
}
if(indexPath.row==3)
{
cell.textLabel.text = #"Quantity";
cell.detailTextLabel.text=[myDict objectForKey:#"Quantity"];
}
if(indexPath.row==4)
{
cell.textLabel.text = #"Pants";
cell.detailTextLabel.text=[myDict objectForKey:#"pants"];
}
if(indexPath.row==5)
{
cell.textLabel.text = #"Shirts";
cell.detailTextLabel.text=[myDict objectForKey:#"shirts"];
}
if(indexPath.row==6)
{
cell.textLabel.text = #"Other";
cell.detailTextLabel.text=[myDict objectForKey:#"other"];
}
if(indexPath.row==7)
{
cell.textLabel.text = #"Start Date";
NSString *str=[myDict objectForKey:#"startDate"];
NSString *str2= [str substringToIndex:10];
cell.detailTextLabel.text=str2;
}
if(indexPath.row==8)
{
cell.textLabel.text = #"End Date";
NSString *str=[myDict objectForKey:#"endDate"];
NSString *str2= [str substringToIndex:10];
cell.detailTextLabel.text=str2;
}
if(indexPath.row==9)
{
cell.textLabel.text = #"Address";
cell.detailTextLabel.text=[myDict objectForKey:#"address"];
}
if(indexPath.row==10)
{
cell.textLabel.text = #"Notes";
cell.detailTextLabel.text=[myDict objectForKey:#"Notes"];
}
if(indexPath.row==11)
{
cell.textLabel.text = #"Bill";
cell.detailTextLabel.text=[myDict objectForKey:#"bill"];
}
if(indexPath.row==12)
{
cell.textLabel.text = #"Grand Total";
cell.detailTextLabel.text=[myDict objectForKey:#"total"];
}
if(indexPath.row==13)
{
cell.textLabel.text = #"Signature";
cell.detailTextLabel.text=[myDict objectForKey:#"sign"];
}
return cell;
}
NSArray do not respond to length, but count.
Most probably in value you expect a NSString, but there is an array instead.
Something is wrong when you set the value.
Might be you are expecting something different and it having other type of values.May be you are expecting NSString and it is giving any other type.
Youc can use id data type so that it can be helpful. This solved for me.Hope for you also.
This:
[myDict objectForKey:[keys objectAtIndex:i]];
is returning an NSArray, not a NSString.
Related
I want to expand and collapse cell when I clicked on the cell at particular index.
I am using auto resize and the data in the cell is dynamic i.e cell size increase based on label content I am using autoresize not autolayouts.
When I click on the cell the cell size will increase and the size to be increase is also dynamic what depends on the label content.
Please find my below code
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
NSInteger numOfSections = 0;
if (tableView==_commentstbl_view) {
return commentsarray.count;
}
else
if (isclassifiedarray.count > 0)
{
_myadstabelview.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
_myadstabelview.backgroundView = nil;
numOfSections = isclassifiedarray.count;
}
else
{
// UILabel *noDataLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, _notificationTblView.bounds.size.width, _notificationTblView.bounds.size.height)];
// noDataLabel.text = #"No Results Found!";
// noDataLabel.textColor = [UIColor blackColor];
// noDataLabel.numberOfLines = 4;
// noDataLabel.textAlignment = NSTextAlignmentCenter;
// _notificationTblView.backgroundView = noDataLabel;
_myadstabelview.separatorStyle = UITableViewCellSeparatorStyleNone;
}
return numOfSections;
return isclassifiedarray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
commentscell = (commentsTableViewCell*)[_commentstbl_view dequeueReusableCellWithIdentifier:#"commentsTableViewCell" forIndexPath:indexPath];
commentscell.selectionStyle = UITableViewCellSelectionStyleNone;
[commentscell.layer setCornerRadius:4.0f];
[commentscell.layer setMasksToBounds:YES];
commentscell.profileimg.layer.cornerRadius=4.0f;
commentscell.profileimg.layer.masksToBounds = YES;
NSString *mobilenumber=[NSString stringWithFormat:#"%#",[[commentsarray objectAtIndex:indexPath.section]valueForKey:#"clubber_mobile"]];
NSString *comment=[[commentsarray objectAtIndex:indexPath.section]valueForKey:#"comment"];
UIFont *font=[UIFont fontWithName:#"Montserrat" size:14.0];
CGFloat size1 = [self getLabelHeightForStringforcomment:commentscell.commentlbl.text font:font];
commentscell.commentlbl.frame=CGRectMake(commentscell.commentlbl.frame.origin.x, commentlbYposition, commentscell.commentlbl.frame.size.width, size1);
commentscell.commentdatelbl.frame=CGRectMake(commentscell.commentdatelbl.frame.origin.x, commentlbYposition+size1, commentscell.commentdatelbl.frame.size.width, commentscell.commentdatelbl.frame.size.height);
commentscell.providerdetailsbtnoutlet.frame=CGRectMake(commentscell.providerdetailsbtnoutlet.frame.origin.x, commentlbYposition+size1+commentscell.commentdatelbl.frame.size.height, commentscell.providerdetailsbtnoutlet.frame.size.width, commentscell.providerdetailsbtnoutlet.frame.size.height);
if (selectedIndex==-1) {
commentscell.providerdetails_view.hidden=YES;
}else{
commentscell.providerdetails_view.hidden=NO;
commentscell.providerdetails_view.frame=CGRectMake(commentscell.providerdetailsbtnoutlet.frame.origin.x, commentlbYposition+size1+commentscell.commentdatelbl.frame.size.height+commentscell.providerdetailsbtnoutlet.frame.size.height, commentscell.providerdetails_view.frame.size.width, Providerdrtailviewhight);
commentscell.providerdetails_view.backgroundColor=[UIColor whiteColor];
}
NSString *commentclubbername=[[commentsarray objectAtIndex:indexPath.section]valueForKey:#"clubber_name"];
NSString *commentclubberid=[NSString stringWithFormat:#"%#",[[commentsarray objectAtIndex:indexPath.section]valueForKey:#"clubberId"]];
NSString *commentposteddate=[NSString stringWithFormat:#"%#",[[commentsarray objectAtIndex:indexPath.section]valueForKey:#"posted_date"]];
NSString *imgUrl = [NSString stringWithFormat:#"%s/presignin/clubber/getImage?clubberId=%#",urlPath,commentclubberid];
NSURL *imageURL=[NSURL URLWithString:imgUrl];
commentscell.profileimg.imageURL=imageURL;
commentscell.usernamelbl.text=commentclubbername;
commentscell.commentlbl.text=comment;
commentscell.commentdatelbl.text=[Util formatDateAndTime1:commentposteddate];
commentscell.callbtn.tag = indexPath.section;
commentscell.msgbtn.tag = indexPath.section;
commentscell.providerdetailsbtnoutlet.tag=indexPath.section;
[commentscell.callbtn addTarget:self action:#selector(callbtnClicked:) forControlEvents:UIControlEventTouchUpInside];
[commentscell.msgbtn addTarget:self action:#selector(messagebtnClicked:) forControlEvents:UIControlEventTouchUpInside];
// [commentscell.providerdetailsbtnoutlet addTarget:self action:#selector(providerdetailsbtnclick:) forControlEvents:UIControlEventTouchUpInside];
commentscell.providerdetailsbtnoutlet.userInteractionEnabled=NO;
NSString *experience=[NSString stringWithFormat:#"%#",[[commentsarray objectAtIndex:indexPath.section]valueForKey:#"experience"]];
NSArray* foo = [experience componentsSeparatedByString: #"."];
if (foo.count==1) {
NSString* year = [foo objectAtIndex: 0];
// NSString* month = [foo objectAtIndex: 1];
expersstr=[NSString stringWithFormat:#"%# Years, 00 Months",year];
commentscell.explbl.text=expersstr;
}else{
NSString* year = [foo objectAtIndex: 0];
NSString* month = [foo objectAtIndex: 1];
expersstr=[NSString stringWithFormat:#"%# Years, %# Months",year,month];
commentscell.explbl.text=expersstr;
}
providerdescr=[NSString stringWithFormat:#"%#",[[commentsarray objectAtIndex:indexPath.section]valueForKey:#"description"]];
commentscell.desclbl.text=providerdescr;
return commentscell;
}
- (CGFloat)tableView:(UITableView* )tableView heightForRowAtIndexPath:(NSIndexPath* )indexPath;
{
UIFont *font=[UIFont fontWithName:#"Montserrat" size:14.0];
// NSString *str1 = [[isclassifiedarray objectAtIndex:indexPath.section]valueForKey:#"description"];
if (tableView==_commentstbl_view) {
if (selectedIndex == indexPath.section)
{
CGFloat size1 = [self getLabelHeightForStringforcomment:[[commentsarray objectAtIndex:indexPath.section]valueForKey:#"comment"] font:font];
// commentscell.providerdetails_view.hidden=NO;
return 104+size1-20+45;
}
else{
CGFloat size1 = [self getLabelHeightForStringforcomment:[[commentsarray objectAtIndex:indexPath.section]valueForKey:#"comment"] font:font];
// commentscell.providerdetails_view.hidden=YES;
return 104+size1-20;
}
}
}
please find the img which is clear idea.
Thanks for quick responce
I have the following code to populate data on the uitableview cell. For some reason, I see every item exactly two on the tableview.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = #"takeStockCell";
UITableViewCell * cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
RackStockTakeStatus *rackStockTakeStatus = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = rackStockTakeStatus.locName;
if ([[rackStockTakeStatus.status lowercaseString] isEqualToString:#"inprogress"])
{
cell.detailTextLabel.textColor = [UIColor blueColor];
cell.detailTextLabel.text = [NSString stringWithFormat:#"%# [%#]",rackStockTakeStatus.status,rackStockTakeStatus.stockTakeByUser];
} else if ([[rackStockTakeStatus.status lowercaseString] isEqualToString:#"completed"])
{
cell.detailTextLabel.textColor = [UIColor colorWithRed:(0/255.0) green:(102/255.0) blue:(0/255.0) alpha:1];
cell.detailTextLabel.text = [NSString stringWithFormat:#"%# [%#]",rackStockTakeStatus.status,rackStockTakeStatus.stockTakeByUser];
} else if ([[rackStockTakeStatus.status lowercaseString] isEqualToString:#"verified"])
{
cell.detailTextLabel.textColor = [UIColor colorWithRed:(0/255.0) green:(102/255.0) blue:(0/255.0) alpha:1];
cell.detailTextLabel.text = [NSString stringWithFormat:#"%# [%#]",rackStockTakeStatus.status,rackStockTakeStatus.stockTakeByUser];
}
}
I am not sure about your method configuring the cell like that. Have you tried to configure it directly into the method cellForRowAtIndexPath ? Not putting the cell as a parameter.
Or just returning the cell in your method configure
cell = [self configureCell...
Im trying to add parse data into my table array and i get'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0] any help on how to resolve this would be appreciated.
PFQuery *query31 = [PFQuery queryWithClassName:#"Salesman"];
[query31 whereKey:#"SalesNo" equalTo:self.tbl22];
// query31.cachePolicy = kPFCachePolicyCacheThenNetwork;
[query31 getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {
if (!object) {
NSLog(#"The getFirstObject request failed.");
} else {
self.salesman = [object objectForKey:#"Salesman"];
NSLog(#"salesStr is %#",self.salesman);
}
}];
tableData2 = [NSArray arrayWithObjects:t21, t22, t23, t24, t25, nil];
here is were i get the crash t22 = self salesman
if ([_formController isEqual: #"Leads"]) {
if ( ( ![t22 isEqual:[NSNull null]] ) && ( [self.tbl22 length] != 0 ) )
{t22 = self.salesman;
} else { t22 = #"None"; }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if ([tableView isEqual:self.listTableView]) {
return [tableData count];
} else if ([tableView isEqual:self.listTableView2]) {
return [tableData count];
} else if ([tableView isEqual:self.newsTableView]) {
return 1;
}
return 0;
}
#pragma mark TableView Delegate Methods
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([tableView isEqual:self.listTableView]) {
static NSString *CellIdentifier = #"NewCell";
UITableViewCell *myCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (myCell == nil) {
myCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; }
//need to reload table (void)viewDidAppear to get fonts to change but its annoying
myCell.textLabel.text = [tableData4 objectAtIndex:indexPath.row];
myCell.textLabel.font = [UIFont systemFontOfSize:8.0];
[myCell.textLabel setTextColor:[UIColor darkGrayColor]];
myCell.detailTextLabel.text = [tableData objectAtIndex:indexPath.row];
myCell.detailTextLabel.font = [UIFont boldSystemFontOfSize:8.0];
[myCell.detailTextLabel setTextColor:[UIColor blackColor]];
return myCell;
}
else if ([tableView isEqual:self.listTableView2]) {
static NSString *CellIdentifier2 = #"NewCell2";
UITableViewCell *myCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
if (myCell == nil) {
myCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2]; }
//need to reload table (void)viewDidAppear to get fonts to change but its annoying
myCell.textLabel.text = [tableData3 objectAtIndex:indexPath.row];
myCell.textLabel.font = [UIFont systemFontOfSize:8.0];
[myCell.textLabel setTextColor:[UIColor darkGrayColor]];
myCell.detailTextLabel.text = [tableData2 objectAtIndex:indexPath.row];
myCell.detailTextLabel.font = [UIFont boldSystemFontOfSize:8.0];
[myCell.detailTextLabel setTextColor:[UIColor blackColor]];
//draw red vertical line
UIView *vertLine = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, myCell.frame.size.height)];
vertLine.backgroundColor = [UIColor redColor];
[myCell.contentView addSubview:vertLine];
return myCell;
}
else if ([tableView isEqual:self.newsTableView]) {
static NSString *CellIdentifier1 = #"detailCell";
CustomTableViewCell *myCell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1 forIndexPath:indexPath];
if (myCell == nil) {
myCell = [[CustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1]; }
//need to reload table (void)viewDidAppear to get fonts to change but its annoying
myCell.separatorInset = UIEdgeInsetsMake(0.0f, myCell.frame.size.width, 0.0f, 400.0f);
myCell.leadtitleLabel.text = self.lnewsTitle;
myCell.leadtitleLabel.numberOfLines = 0;
myCell.leadtitleLabel.font = [UIFont systemFontOfSize:12.0];
[myCell.leadtitleLabel setTextColor:[UIColor darkGrayColor]];
myCell.leadsubtitleLabel.text = #"Yahoo Finance 2 hrs ago";
myCell.leadsubtitleLabel.font = [UIFont systemFontOfSize:8.0];
[myCell.leadsubtitleLabel setTextColor:[UIColor grayColor]];
myCell.leadreadmore.text = #"Read more";
myCell.leadreadmore.font = [UIFont systemFontOfSize:8.0];
myCell.leadnews.text = comments;
myCell.leadnews.numberOfLines = 0;
myCell.leadnews.font = [UIFont boldSystemFontOfSize:8.0];
[myCell.leadnews setTextColor:[UIColor darkGrayColor]];
return myCell;
}
when i run log i get one result Salesman name
NSLog(#"salesStr is %#",self.salesman);
salesStr is Adam Monteleone
It means that you array is empty and you try to access the index 1 which is not able to get it. You better debug yourself.
And if you want to do the introspection on the NSString, you only need to use the length method to check. It will return false if your NSString is either nil or empty.
What I want to do here is set it so that if top3ArrayForSection.count-1 < 1, set the _results bool value of that respective section to NO, and so on. What's happening instead, is that _results is set to NO or YES for the entire table overall, so that I end up with a result like this:
When only the "xperia Z3 compact unlocked" section should say "no items found etc." because it has no cells, the other sections cells shouldn't.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSDictionary *currentSectionDictionary = _matchCenterArray[section];
NSArray *top3ArrayForSection = currentSectionDictionary[#"Top 3"];
if (top3ArrayForSection.count-1 < 1){
_results = NO;
_rowCount = 1;
}
else if(top3ArrayForSection.count-1 >= 1){
_results = YES;
_rowCount = top3ArrayForSection.count-1;
}
return _rowCount;
}
// Cell layout
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Initialize cell
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
// if no cell could be dequeued create a new one
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// No cell seperators = clean design
tableView.separatorColor = [UIColor clearColor];
if (_results == NO) {
// title of the item
cell.textLabel.text = #"No items found, but we'll keep a lookout for you!";
cell.textLabel.font = [UIFont boldSystemFontOfSize:12];
}
else if (_results == YES) {
// title of the item
cell.textLabel.text = _matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Title"];
cell.textLabel.font = [UIFont boldSystemFontOfSize:14];
// price of the item
cell.detailTextLabel.text = [NSString stringWithFormat:#"$%#", _matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Price"]];
cell.detailTextLabel.textColor = [UIColor colorWithRed:0/255.0f green:127/255.0f blue:31/255.0f alpha:1.0f];
// image of the item
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:_matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Image URL"]]];
[[cell imageView] setImage:[UIImage imageWithData:imageData]];
}
return cell;
}
Your instance variable _results is one-dimensional. You could replace it with an NSArray and store the values individually, or you could change the logic in your code as such:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSDictionary *currentSectionDictionary = _matchCenterArray[section];
NSArray *top3ArrayForSection = currentSectionDictionary[#"Top 3"];
return (top3ArrayForSection.count-1 < 1) ? 1 : top3ArrayForSection.count-1;
}
// Cell layout
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Initialize cell
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
// if no cell could be dequeued create a new one
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// No cell seperators = clean design
tableView.separatorColor = [UIColor clearColor];
NSDictionary *currentSectionDictionary = _matchCenterArray[indexPath.section];
NSArray *top3ArrayForSection = currentSectionDictionary[#"Top 3"];
if (top3ArrayForSection.count-1 < 1) {
// title of the item
cell.textLabel.text = #"No items found, but we'll keep a lookout for you!";
cell.textLabel.font = [UIFont boldSystemFontOfSize:12];
}
else {
// title of the item
cell.textLabel.text = _matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Title"];
cell.textLabel.font = [UIFont boldSystemFontOfSize:14];
// price of the item
cell.detailTextLabel.text = [NSString stringWithFormat:#"$%#", _matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Price"]];
cell.detailTextLabel.textColor = [UIColor colorWithRed:0/255.0f green:127/255.0f blue:31/255.0f alpha:1.0f];
// image of the item
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:_matchCenterArray[indexPath.section][#"Top 3"][indexPath.row+1][#"Image URL"]]];
[[cell imageView] setImage:[UIImage imageWithData:imageData]];
}
return cell;
}
In viewDidLoad I add
[super viewDidLoad];
if ([[API sharedInstance] isAuthorized]) {
[self userInfo];
}
then
-(void)userInfo{
API* apiUser = [API sharedInstance];
//load the caption of the selected photo
[apiUser commandWithParams: [NSMutableDictionary dictionaryWithObjectsAndKeys:#"get_user_data", #"command", nil] onCompletion:^(NSDictionary *json) {
//got stream
NSArray* list = [json objectForKey:#"result"];
NSDictionary* userInfo = [list objectAtIndex:0];
name = [NSString stringWithFormat:#"%# %#",[userInfo objectForKey:#"name"], [userInfo objectForKey:#"surname"]];
}];
}
finally cell.textLabel.text and cell.textLabel.font got nothing, text is the same as in storyboard and font is default
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [self.menuItems objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (indexPath.row == 0) {
if (name != nil) {
cell.textLabel.text = name;
}
cell.contentView.backgroundColor = [UIColor colorWithRed:0.8 green:0.0 blue:0.03 alpha:1.0];
UIFont *myfontTop = [ UIFont fontWithName:#"myFont" size:IS_PAD?17:11];
cell.detailTextLabel.font = myfontTop;
cell.textLabel.textColor = [UIColor blueColor];
} else {
UIFont *myfont = [ UIFont fontWithName:#"myFont" size:IS_PAD?17:11];
cell.contentView.backgroundColor = [UIColor grayColor];
cell.textLabel.font = myfont;
}
return cell;
}
Does anyone know how to resolve the problem?