So I have a PersonDoc.h file with the following code:
#import <Foundation/Foundation.h>
@class PersonData;
@interface PersonDoc : NSObject
@property (strong) PersonData *data;
@property (strong) UIImage *thumbImage;
- (id)initWithTitle:(NSString*)name gift:(NSString*)gift thumbImage:(UIImage *)thumbImage;
However, my PersonDoc.m file keeps giving me a warning symbol saying Incomplete Implementation. Heres the .m code:
#import "PersonDoc.h"
#import "PersonData.h"
@implementation PersonDoc
@synthesize data = _data;
@synthesize thumbImage = _thumbImage;
- (id)initWithTitle:(NSString*)title gift:(NSString *)gift thumbImage:(UIImage *)thumbImage fullImage:(UIImage *)fullImage {
if ((self = [super init])) {
self.data = [[PersonData alloc] initWithTitle:title gift:gift];
self.thumbImage = thumbImage;
}
return self;
}
@end
PersonData.h code:
#import
@interface PersonData : NSObject
@property (strong) NSString *name;
@property (assign) NSString *gift;
- (id)initWithTitle:(NSString*)name gift:(NSString*)gift;
@end
PersonData.m code:
#import "PersonData.h"
@implementation PersonData
@synthesize name = _name;
@synthesize gift = _gift;
- (id)initWithTitle:(NSString*)name gift:(NSString*)gift {
if ((self = [super init])) {
self.name = name;
self.gift = gift;
}
return self;
}
@end
In my viewcontroller, Im getting an error saying property name and gift not found on object of type PersonDoc. The following code is in my ViewController:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
// Configure the cell...
// Create the cell
UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:@"PersonCell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"PersonCell"];
}
PersonDoc *person = [self.people objectAtIndex:indexPath.row];
cell.textLabel.text = person.name;
cell.detailTextLabel.text = person.gift;
cell.imageView.image = person.thumbImage;
return cell;
}
I know it has something to do with the initWithTitle code in my .h file so can anyone show me the proper way how to do initWithTitle for both my .h and .m file? Thanks, I really appreciate any help guys!
The
initWithTitlein your header and implementation have different signatures according to the code you posted. Fix that, and your warning should go away