在'UIViewController *'类型的对象上找不到属性'images' [英] Property 'images' not found on object of type 'UIViewController *'
问题描述
我正在尝试合并这两个项目。
I'm trying to merge these two projects.
此时我只是试图将它们保存在单独的视图控制器中,并使Thumbnail Picker的功能在它自己的控制器中工作。
At this point I'm just trying to keep these in separate view controllers and getting the functionality of the Thumbnail Picker working in it's own controller.
我收到错误,如标题中所述,在'UIViewController *'类型的对象上找不到属性'图像'
I'm getting the error, as stated in the title, "Property 'images' not found on object of type 'UIViewController *'"
错误来自AppDelegate.m文件:
The error is coming from the AppDelegate.m file:
#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[UIViewController alloc] init];
NSArray *paths = [[NSBundle mainBundle] pathsForResourcesOfType:@"jpg" inDirectory:nil];
NSMutableArray *images = [NSMutableArray arrayWithCapacity:paths.count];
for (NSString *path in paths) {
[images addObject:[UIImage imageWithContentsOfFile:path]];
}
self.viewController.images = images;
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
@end
这是AppDelegate.h:
Here is the AppDelegate.h:
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIViewController *viewController;
@end
我试过声明这样的属性:
I've tried declaring a property like so:
@property (strong, nonatomic) UIImageView *images;
即使我精心合并这两个代码库,我似乎无法解决这个问题。
I can't seem to fix this even though I painstakingly merged these two codebases.
这是我现在所处的Xcode项目:
Here is the Xcode project of where I'm at at this point:
推荐答案
您在.h文件中声明的 images
属性:
the "images
" property you've declared in your .h file:
@property (strong, nonatomic) UIImageView *images;
不是您尝试通过此行分配给它的NSMutableArray:
is not the NSMutableArray you are trying to assign to it via this line:
self.viewController.images = images;
如果你可以得到相同的类型(即一个UIImageView对象或一个NSMutableArray包含许多UIImages),那么你应该把更好的运气分配给那个属性。
If you can get the types to be the same (i.e. either a single UIImageView object or a NSMutableArray containing many UIImages), then you should have better luck with assigning things to that property.
这篇关于在'UIViewController *'类型的对象上找不到属性'images'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!