views:

476

answers:

4

if (cell == nil) {

//cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 260, 44) reuseIdentifier:CellIdentifier] autorelease];

//The line above works like a breeze

cell = [[[UITableViewCell alloc] initWithStyle:initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; //This is the line that is causing me problems }


These are the error logs:

/Users/myname/Downloads/myApp/Classes/MyTableView.m: In function '-[MyTableView tableView:cellForRowAtIndexPath:]':

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: error: 'initWithStyle' undeclared (first use in this function)

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: error: (Each undeclared identifier is reported only once

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: error: for each function it appears in.)

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: error: 'UITableViewCellStyleValue1' undeclared (first use in this function)

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: warning: no '-initWithStyle::reuseIdentifier:' method found

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: warning: (Messages without a matching method signature

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: warning: will be assumed to return 'id' and accept

/Users/myname/Downloads/myApp/Classes/MyTableView.m:88: warning: '...' as arguments.)

Any help will be appreciated

+1  A: 

The correct method is

initWithStyle:reuseIdentifier:

You are using instead

initWithStyle:initWithStyle:reuseIdentifier:

Simply delete the redundant initWithStyle: and it will work.

unforgiven
A: 

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


Still I get the following errors:

/Users/myName/Downloads/myApp/Classes/MyTable.m: In function '-[MyTable tableView:cellForRowAtIndexPath:]':

/Users/myName/Downloads/myApp/Classes/MyTable.m:88: error: 'UITableViewCellStyleValue1' undeclared (first use in this function)

/Users/myName/Downloads/myApp/Classes/MyTable.m:88: error: (Each undeclared identifier is reported only once

/Users/myName/Downloads/myApp/Classes/MyTable.m:88: error: for each function it appears in.)

/Users/myName/Downloads/myApp/Classes/MyTable.m:88: warning: no '-initWithStyle:reuseIdentifier:' method found

/Users/myName/Downloads/myApp/Classes/MyTable.m:88: warning: (Messages without a matching method signature

/Users/myName/Downloads/myApp/Classes/MyTable.m:88: warning: will be assumed to return 'id' and accept

/Users/myName/Downloads/myApp/Classes/MyTable.m:88: warning: '...' as arguments.)

Minar
Make sure the name of the method is spelled correctly as well. -(id)initWithStyle:(UITableViewCellStyle)stylereuseIdentifier:(NSString *)reuseIdentifier;
willc2
+1  A: 

Are you compiling for OS 3? I don't believe UITableViewCellStyleValue1 existed in OS 2...

Jongsma
how do you check that? I believed I am compiling for OS 3
Minar
Check project info, General section "Base SDK for All Configurations": does it iPhone Device 3.0?
JOM
A: 

UITableViewCellStyleValue1 was not defined in SDKs prior to 3.0. Check the SDK you are using.

mahboudz
Jongsma said it first.
mahboudz