0
我需要建立一個應用程序,定義應該由圖像項目組成的數組。 每個圖像都有一個圖像,一個名字和一個攝影師的名字。 我建立我的圖像項目類,我希望你檢查我的定義是否正確和好(我剛開始學習目標c)。 我希望你強調該套的方法。imageitem類定義
這裏是photoitem.h:
#import <Foundation/Foundation.h>
@interface photoItem : NSObject
{
UIImage *imageView;
NSString *photoNameLabel;
NSString *photographerNameLabel;
UIButton *viewPhoto;
}
@property(readonly) NSString *name;
@property(readonly) NSString *nameOfPhotographer;
@property(readonly) UIImage *imageItem;
-(id)makePhotoItemWIthPhoto:(UIImage*)image name:(NSString*)photoName photographer: (NSString*)photographerName;
@end
這裏是我的photoitem.m:
#import "photoItem.h"
@implementation photoItem
@synthesize name;
@synthesize nameOfPhotographer;
@synthesize imageItem;
-(id)makePhotoItemWIthPhoto:(UIImage*)image name:(NSString*)photoName photographer:(NSString*)photographerName
{
[self setName:photoName];
[self setNameOfPhotographer:photographerName];
[self setImageItem:image];
return self;
}
-(void) setName:(NSString *)name
{
photoNameLabel = name;
}
-(void) setNameOfPhotographer:(NSString *)nameOfPhotographer
{
photographerNameLabel = nameOfPhotographer;
}
-(void)setImageItem:(UIImage *)imageItem
{
imageView = imageItem;
}
@end
我希望你能解決我的錯誤(如果有一些)。 謝謝。