Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 714
  • Last Modified:

basic question in IOS5

Hi what is wrong with this code, Xcode is giving me "expected identifier" error  in the last statement

 -(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];
                 
    }

Open in new window

0
Rozamunda
Asked:
Rozamunda
  • 2
1 Solution
 
Hamidreza VakilianSenior iOS DeveloperCommented:
Because the left and right brackets are not balanced on line 9. (one extra left bracket).

Try:

-(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];
                 
    }

Open in new window

0
 
RozamundaAuthor Commented:
They are balanced 2 opening brackets, 2 closing
0
 
Hamidreza VakilianSenior iOS DeveloperCommented:
The last line of the snippet you provided in your question looks like:
...... [[[theTableViewCell ......
 3 openning brackets and 2 closing.

Which I corrected it in my previous comment.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now