2012-01-02 45 views
3

我收到了這個我找不到的錯誤。ARC錯誤:實例消息的接收方類型沒有聲明選擇方法

error: Automatic Reference Counting Issue: Receiver type 'pageAppViewController' for instance message does not declare a method with selector '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; 

} 
+0

你應該在這裏顯示你的@interface。 – StilesCrisis 2012-01-02 15:37:18

回答

7

有你的控制器的.h文件的

- (NSArray *) createContentPages; 

方法的聲明?

+0

我沒有這個聲明。我剛剛添加它,它的工作。非常感謝!! – ctw 2012-01-02 15:40:28

+0

我的一位同事擁有最新版本的LLVM,並且該消息不再出現。我不記得哪一個是,但似乎他們已經刪除了在「@ interface」內聲明方法的需要,它們的定義和用法僅限於'@ implementation'。 – elitalon 2012-08-22 15:56:50

+0

是的,新的LLVM版本更具用戶友好性和容錯性。但它總是一個好主意,在@interface塊中用一些註釋聲明你的方法。 – CarlJ 2012-08-22 16:00:22

相關問題