Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8394445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:03:53+00:00 2026-06-09T20:03:53+00:00

New to objective c. I am using NSArray to populate my UITableView . is

  • 0

New to objective c. I am using NSArray to populate my UITableView. is there a way to remove the blank from the array and from the cell.textLabel.text. This is what i have done:

- (void)viewDidLoad
{
    [super viewDidLoad];
    alTableView.delegate = self;
    alTableView.dataSource = self;
    NSArray *BusRoute = alightDesc;
    int i;
    int count = [BusRoute count];
    for (i = 0; i < count; i++)
    {  
        NSDictionary *STEPS = [dic valueForKey:@"STEPS"];            
        alDescArray = [[STEPS valueForKey:@"AlightDesc"] retain];
        boardDescArray = [[STEPS valueForKey:@"BoardDesc"] retain];   
        NSLog(@"boardDescArray = %@", boardDescArray);     

        serviceID = [[STEPS valueForKey:@"ServiceID"] retain];
    }
}

- (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] autorelease];
    }
    cell.textLabel.font = [UIFont systemFontOfSize:14]; //Change this value to adjust size
    cell.textLabel.numberOfLines = 10;
    cell.textLabel.text = [NSString stringWithFormat:@"Walk to and board at %@\nTake Bus Service = %@\nAlight Destination = %@",[boardDescArray objectAtIndex:indexPath.row], [serviceID objectAtIndex:indexPath.row], [alDescArray objectAtIndex:indexPath.row]];
    NSLog(@"cell = %@", cell.textLabel.text);
    return cell;
}

At the second cell print out, Walk to and board at (Null) is there a way to remove that sentence from the table?

Results:

alDescArray = (
"OPP",
"OPP",
"OPP"
)

boardDescArray = (
"BLK",
"AFT",
""
)

serviceID = (
66,
43,
72
)

cell = Walk to and board at BLK 7
       Take Bus Service = 11
       Alight Destination = BLK 11
cell = Walk to and board at 
       Take Bus Service = 3
       Alight Destination = BLK 16
cell = Walk to and board at BLK 38 
       Take Bus Service = 9
       Alight Destination = AA

Update Ans

- (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] autorelease];
}
cell.textLabel.font = [UIFont systemFontOfSize:14]; //Change this value to adjust size
cell.textLabel.numberOfLines = 10;

NSString *boardDesc = [boardDescArray objectAtIndex:indexPath.row];
NSString *serviceId = [serviceID objectAtIndex:indexPath.row];
NSString *alDesc = [alDescArray objectAtIndex:indexPath.row];
NSLog(@"serviceId - %@",serviceId);

NSString *resultString2 = [NSString stringWithString:@""];

//make a check before making the string
if ([boardDesc length]>0) {
    resultString2 =[resultString2 stringByAppendingFormat:@"Walk to and board at %@,",boardDesc];
}

if ([serviceId length]>0) {
    resultString2 =[resultString2 stringByAppendingFormat:@"Take Bus Service %@: ",serviceId];
}

if ([alDesc length]>0) {
    resultString2 =[resultString2 stringByAppendingFormat:@"Alight Destination %@: ",alDesc];
}

//string that doesnot print null values
NSLog(@"resultString2 - %@",resultString2);
cell.textLabel.text = resultString2;
NSLog(@"cell = %@", cell.textLabel.text);
return cell;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:03:55+00:00Added an answer on June 9, 2026 at 8:03 pm
    NSString *myName = [NSString stringWithString:@"Mangesh"];
    NSString *myAge = [NSString stringWithString:@""];
    NSString *myProfession = [NSString stringWithString:@"Developer"];
    //just for example you have three string with above values 
    //and you want to print Hi, My Name is ABC, I am 22 year old and my Profession is Developer
    
    //string that prints null values     
    NSString *resultString1 = [NSString stringWithFormat:@"Hi, My Name is %@, I am %@ year old and my profession is %@",myName,myAge,myProfession];
    
    NSLog(@"resultString1 - %@",resultString1);
    //output: resultString1 - Hi, My Name is Mangesh, I am  year old and my profession is Developer
    
    NSString *resultString2 = [NSString stringWithString:@"Hi,"];
    
    //make a check before making the string
    if ([myName length]>0) {
        resultString2 =[resultString2 stringByAppendingFormat:@"My Name is %@,",myName];
    }
    
    if ([myAge length]>0) {
        resultString2 =[resultString2 stringByAppendingFormat:@"I am %@ year old and",myAge];
    }
    
    if ([myProfession length]>0) {
        resultString2 =[resultString2 stringByAppendingFormat:@" my profession is %@",myProfession];
    }
    
    //string that doesnot print null values
    NSLog(@"resultString2 - %@",resultString2);
    //output:-  resultString2 - Hi,My Name is Mangesh, my profession is Developer
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a new objective-c/iPhone developer and am wondering if there is any way
I am a new objective-c/iPhone developer and am wondering if there is any way
I'm new to Objective C and I've been trying to do Segue using a
I am new to Objective-C and iPhone I have to sort a NSDictionary using
I am new to Objective C and iPhone development. I am using CoreData on
I am new to RubyMotion for iOS app, but I coded using Objective C.
I want to start a new thread using a C function, not an objective-C
I'm new to Objective-C and iPhone development and have been using Apress' Beginning iPhone
I'm new to Objective-C and I'd like to abstract my database access using a
I am passing a string from objective C to javascript in this way -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.