いくつかのクラスを含むアプリケーションを作成しました。「photoItem」という名前のクラスの1つとそのクラスには、画像アイテムとメソッドが含まれています。
appDelagateでそのメソッドを使用しようとしましたが、機能しませんでした。
私のphotoitem.hは:#import
@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
そして私のappdelagateは:
#import "AppDelegate.h"
#import "PersonListViewController.h"
#import "RecentsViewController.h"
#import "PhotoListViewController.h"
#import "photoItem.h"
@implementation AppDelegate
@synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
photoArray = [[NSMutableArray alloc] init];
[photoArray addObject:[photoItem XXXXXX];
}
最後の行にメソッドを実装したい:[photoArray addObject:[photoItem XXXXXX]しかし、xcodeではこのメソッドを選択して使用することができませんでした。
何が問題ですか?