views:

461

answers:

3

I am new to objective-c programming. I come from a C# background. I am having problems with the following code I am writing for a proof of concept for an iPhone App:

I am getting a number of compile errors but I think they are all due to the first error (could be wrong) - error: expected identifier before '*' token (@synthesize *lists; in the .m file)

I'm not sure why my code is showing up the way it is in the view below the editor..hmm any way, any help would be appreciated.

.m file

//
//  Created by Aaron Levin on 4/19/10.
//  Copyright 2010 RonStan. All rights reserved.
//

#import "UIViewerTableViewController.h"

@implementation UIViewerTableViewController

@synthesize *lists;
@synthesize *icon;

- (void)dealloc {
 [Lists release];
    [super dealloc];
}

#pragma mark Table View Methods

//Customize number of rows in table view

- (NSInteger)tableView:(UITableView *) tableView numberOfRowsInSection: (NSInteger) section{

 return self.Lists.Count;
}

//Customize the appearence of table view cells

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

 static NSString *CellIdentifier = @"Cell";

 UITableView *Cell =  [tablevView dequeueReusableCellWithIdentifier:CellIdentifier];

 if(cell == nil){

  cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];  
 }

 cell.textLabel.text = [[self.Lists objectAtIndex:indexPath.row] retain];

 cell.imageView = self.Icon;

 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

}

@end

.h file

//
//  UIMyCardsTableViewController.h
//  MCS ProtoType v0.1
//
//  Created by Aaron Levin on 4/19/10.
//  Copyright 2010 RonStan. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIViewerTableViewController : UITableViewController {

 NSArray  *lists;
 UIImage *icon;

}

@property (nonatomic,retain) NSArray  *lists;
@property (nonatomic,retain) UIImage *icon;

@end
+4  A: 

@synthesize *lists; should be @synthesize lists;

This assumes the private member you're providing access to is called lists which seems to be true for your code above.

PS - you can format your code using the '1010' button in the editor toolbar, or by enclosing in backticks.

psychotik
A: 

same holds true for @synthesize *icon; You need to change it to @synthesize icon;

Hetal Vora
A: 

Thanks for your prompt reply. When I change the @synthesize *lists; to @synthesize lists; I get the following error:

Request for member 'Count'in something not a structure or union. on return self.lists.Count;

Below is the modified code. Any help would be greatly appreciated. Thanks.

.m file

//  Created by Aaron Levin on 4/19/10.
//  Copyright 2010 RonStan. All rights reserved.
//

#import "UIViewerTableViewController.h"


@implementation UIViewerTableViewController


@synthesize lists;

@synthesize icon;



- (void)dealloc {
    [lists release];
    [super dealloc];
}


#pragma mark Table View Methods

//Customize number of rows in table view

- (NSInteger)tableView:(UITableView *) tableView numberOfRowsInSection: (NSInteger) section{

    return self.lists.Count;

}

//Customize the appearence of table view cells

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

    static NSString *CellIdentifier = @"Cell";
    UITableView *Cell =  [tablevView dequeueReusableCellWithIdentifier:CellIdentifier];

    if(cell == nil){

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];        
    }

    cell.textLabel.text = [[self.Lists objectAtIndex:indexPath.row] retain];
    cell.imageView = self.Icon;

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

}

@end

.h file

// UIMyCardsTableViewController.h 
// MCS ProtoType v0.1  
// Created by Aaron Levin on 4/19/10. 
// Copyright 2010 RonStan. All rights reserved. //

import
@interface UIViewerTableViewController : UITableViewController {

NSArray *lists;

UIImage *icon;

}

@property (nonatomic,retain) NSArray *lists;

@property (nonatomic,retain) UIImage *icon;

@end
The Professor
Try changing Count to count (lowercase c). Objective-C is case-sensitive. BTW, you should have updated your question with this instead of posting an Answer.
DyingCactus