2011-06-21 30 views
0

我是Objective-C的新手,尽管我在Android中有非常好的一面。我试图调用一个方法,但它给了我'首次在函数中使用'。我知道我犯了一个愚蠢的错误,但专家可以轻松搞定。未声明 - '首次在函数中使用'

RootViewController.h

#import <UIKit/UIKit.h> 
#import "ContentViewController.h" 

@interface RootViewController : UITableViewController { 
    ContentViewController *contentViewController; 
} 

@property (nonatomic, retain) ContentViewController *contentViewController; 

- (NSString*)getContentFileName:(NSString*)title; //<--- This function declartion 

@end 

RootViewController.m

#import "RootViewController.h" 
#import "HAWATAppDelegate.h" 
#import "ContentViewController.h" 

@implementation RootViewController 
@synthesize contentViewController; 

... 
more methods 
... 

#pragma mark - 
#pragma mark Table view delegate 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    HAWATAppDelegate *appDelegate = (HAWATAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    NSString *title = (NSString *) [appDelegate.titles objectAtIndex:indexPath.row]; 

    NSString *fileName = getContentFileName:title; //<--- Here is the error 

    ... 
} 

- (NSString*) getContentFileName:(NSString*)title { 
    return [title lowercaseString]; 
} 

@end 

必须有我缺少一个简单的事情。请告诉我。提前致谢。

回答

5

OMG !!这应该是[self getContentFileName:title];

+1

哇!谢谢@EmptyStack。现在工作。将在12分钟内接受您的答案;) –

+1

OOOOMMMMGGGG,优胜者鸡冠晚餐。 –

+0

@Ragunath Jawahar,欢迎 – EmptyStack

1

你打电话的方法是错的。在Objective-C调用方法的格式为:

[object selectorWithArgument:foo bar:baz]; 

所以有错误的行应该是:

NSString *fileName = [self getContentFileName:title]; //<--- Here is the error 
+0

谢谢@ErikPerik –

相关问题