我构建了一个包含多个类的应用程序。其中一个名为“photoItem”的类包含一个图像项和一个方法。
我尝试在我的 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
我的应用程序是:
#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没有让我选择和使用这个方法。
问题是什么?