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 3224804
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:15:57+00:00 2026-05-17T16:15:57+00:00

I am getting a weird compilation error – I dont know if there is

  • 0

I am getting a weird compilation error – I dont know if there is a “ghost in the machine” or what?

Below if the code snippet where I am getting this error

   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
    }



 cell.selectionStyle = UITableViewCellSelectionStyleNone;

 if (indexPath.section == 0) {

  switch (indexPath.row) {
   case 0:
    cell.textLabel.text = @"User";
    cell.detailTextLabel.text = @"John Smith";
    break; 
   case 1:
    cell.textLabel.text = @"From";
    cell.detailTextLabel.text = @"12/01/2010";
    break;
   case 2:
    cell.textLabel.text = @"To";
    cell.detailTextLabel.text = @"12/02/2010";
    break;
   case 3:
    cell.textLabel.text = @"Duration";
    cell.detailTextLabel.text = @"30 Days";
    break;
   case 4:
    UITextView *commentsView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];
    //commentsView.layer.cornerRadius = 10.0f;
    //[cell.contentView addSubview:commentsView];
    //[commentsView release];
    break;
   default:
    break;
  }
    } else if (indexPath.section == 1) {
  cell.detailTextLabel.text = @"Approve";  
 } else {
  cell.detailTextLabel.text = @"Reject";
 }
    // Configure the cell...

    return cell;
}

I am getting following error

/Users/dk/Desktop/xxx/Classes/DetailedLeaveRequestViewController.m:103:0 
/Users/dk/Desktop/xxx/Classes/DetailedLeaveRequestViewController.m:103: error: expected expression before 'UITextView'

at line

UITextView *commentsView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];

in the case 4:

I double-checked the syntax and everything over and over but could not find any problems.
The weird part is when I tried to compile the line below last line of case 3: (just above the break;) it compiled and ran correctly.
Can we not declare and initialize an object inside a case statement?
Am I missing something fairly basic here?

Thanks.

  • 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-05-17T16:15:57+00:00Added an answer on May 17, 2026 at 4:15 pm

    You need to add a block limiter to your case statement:

    case 4:{
        UITextView *commentsView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];
    }
    

    or move variable declaration outside of switch statement

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting this weird compilation error with eclipse in the following code block. I've
Getting this weird LINQ error. title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String Here is the code I have:
i'm getting a weird null pointer exception in the last line of this code:
I am getting a couple of weird compilation errors. This is for a homework
I'm getting weird results from the System.out.print immediately below the Scanner declaration in the
I'm getting a weird error, when initializing my deque or vector. I'm using QtCreator
I'm getting this weird issue. Basically I'm animating a view with translate animation. (Translate
It's kinda weird. I'm getting a huge error, and have got no clue where
I'm getting weird error and I have no idea how to resolve it. I've
i am getting weird python bus error when building a web app. http://pastie.org/714569 i

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.