ARC 错误:实例消息的接收者类型未声明带有选择器的方法

发布于 2024-12-23 12:56:05 字数 2999 浏览 3 评论 0原文

我收到这个错误,我无法弄清楚。

错误:自动引用计数问题:接收器类型“pageAppViewController”(例如消息)未使用选择器“createContentPages”声明方法

我在下面发布了我的代码。我的类 pageAppViewController 中有一个名为 createContentPages 的方法。这意味着什么以及造成这种情况的原因是什么?

//  contentViewController.m

#import "contentViewController.h"
#import "pageAppViewController.h"

@implementation contentViewController

@synthesize theImageView, dataObject;
@synthesize image;

- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

//error occurs on this next line    
pageAppViewController *newContent = [[pageAppViewController alloc] init];
self.image = [newContent createContentPages];
[self.theImageView setImage:  ((pageAppViewController *) [self.image objectAtIndex:0]) .images];


}

error: Automatic Reference Counting Issue: Receiver type 'pageAppViewController' for instance message does not declare a method with selector 'createContentPages'


//
//  pageAppViewController.m

#import "pageAppViewController.h"

@implementation pageAppViewController
@synthesize pageController;

@synthesize bookContent;

@synthesize images;


- (NSArray *) createContentPages
{

    UIImage *zero = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"TitlePage.png"]];
    UIImage *one = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"Page1.png"]];
    UIImage *two = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"Page2.png"]];
    UIImage *three = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"Page3.png"]];
    UIImage *four = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"Page4.png"]];
    UIImage *five = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"Page5.png"]];

    NSMutableArray *pageContent = [[NSMutableArray alloc] init];


    for (int i = 1; i < 7; i++)
    {
    pageAppViewController *content = [[pageAppViewController alloc] init];

    if (i == 1)
    {
        content.images = zero;
        [pageContent addObject:content];

         }

    else if (i == 2)
    {
        content.images = one;
       [pageContent addObject:content];
    }

    else if (i == 3)
    {
        content.images = two;   
        [pageContent addObject:content];
    }

    else if (i == 4)
    {
        content.images = three;
        [pageContent addObject:content];
    }

    else if (i == 5)
    {
        content.images = four;
        [pageContent addObject:content];
    }

    else if (i == 6)
    {
        content.images = five;
        [pageContent addObject:content];
    }
    }

     bookContent = [[NSArray alloc] initWithArray: pageContent];

    return bookContent;

}

I am getting this error that I can't figure out.

error: Automatic Reference Counting Issue: Receiver type 'pageAppViewController' for instance message does not declare a method with selector 'createContentPages'

I posted my code below. I do have a method called createContentPages in my class pageAppViewController. What does this mean and what is causing it?

//  contentViewController.m

#import "contentViewController.h"
#import "pageAppViewController.h"

@implementation contentViewController

@synthesize theImageView, dataObject;
@synthesize image;

- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

//error occurs on this next line    
pageAppViewController *newContent = [[pageAppViewController alloc] init];
self.image = [newContent createContentPages];
[self.theImageView setImage:  ((pageAppViewController *) [self.image objectAtIndex:0]) .images];


}

error: Automatic Reference Counting Issue: Receiver type 'pageAppViewController' for instance message does not declare a method with selector 'createContentPages'


//
//  pageAppViewController.m

#import "pageAppViewController.h"

@implementation pageAppViewController
@synthesize pageController;

@synthesize bookContent;

@synthesize images;


- (NSArray *) createContentPages
{

    UIImage *zero = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"TitlePage.png"]];
    UIImage *one = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"Page1.png"]];
    UIImage *two = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"Page2.png"]];
    UIImage *three = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"Page3.png"]];
    UIImage *four = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"Page4.png"]];
    UIImage *five = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"Page5.png"]];

    NSMutableArray *pageContent = [[NSMutableArray alloc] init];


    for (int i = 1; i < 7; i++)
    {
    pageAppViewController *content = [[pageAppViewController alloc] init];

    if (i == 1)
    {
        content.images = zero;
        [pageContent addObject:content];

         }

    else if (i == 2)
    {
        content.images = one;
       [pageContent addObject:content];
    }

    else if (i == 3)
    {
        content.images = two;   
        [pageContent addObject:content];
    }

    else if (i == 4)
    {
        content.images = three;
        [pageContent addObject:content];
    }

    else if (i == 5)
    {
        content.images = four;
        [pageContent addObject:content];
    }

    else if (i == 6)
    {
        content.images = five;
        [pageContent addObject:content];
    }
    }

     bookContent = [[NSArray alloc] initWithArray: pageContent];

    return bookContent;

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小糖芽 2024-12-30 12:56:06

你有

- (NSArray *) createContentPages;

控制器的 .h 文件中的方法声明吗?

have you the

- (NSArray *) createContentPages;

Method declaration in the .h File of the Controller?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文