0

在方法声明和调用上有一个奇怪的错误......

MyObject.h --- declarations. has been trimmed down
#import <Foundation/Foundation.h>

@interface MyObject : NSObject

- (void) useFlattenHTML;
- (NSString *) flattenHTML:(NSString *) inHtml;
- (NSString *) justAStringMethod;

@end

像这样定义和调用的方法......

MyObject.m --- method declaration and usage. Trimmed down
#import "MyObject.h"

@implementation MyObject
- (NSString *) flattenHTML:(NSString *) inHtml {
NSScanner *theScanner;
NSString *text = nil;
theScanner = [NSScanner scannerWithString:inHtml];
while ([theScanner isAtEnd] == NO) {
    [theScanner scanUpToString:@"<" intoString:NULL] ;
    [theScanner scanUpToString:@">" intoString:&text] ;
    inHtml = [inHtml stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@>", text] withString:@""];
}
//
inHtml = [inHtml stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
return inHtml;
}

- (NSString *) justAStringMethod
{
    // Some calls.
}

- (void) useFlattenHTML
{
    NSString* resultStr = [self.flattenHTML @"Some html tagged string"];
    NSString* anotherStr = [self.justAStringMethod]; 
}   

@end

我明白了

 Property 'flattenHTML' not found on object of type 'MyObject *'
4

1 回答 1

3

也许是因为您在没有多大意义的情况下使用点符号:在useFlattenHTML方法中,self.flattenHTML与 相同[self flattenHTML],它不存在,因为您只有[self flattenHTML:someString].

最重要的是,点表示法是可能的,但你应该为声明为@propertyonly的字段保留它

于 2013-09-02T15:46:11.447 回答