我有类别问题:在选择器“isUrl”中声明“NSString”没有可见的@interface
NSString+NSString.h
#import <Foundation/Foundation.h>
@interface NSString (NSString)
- (BOOL)isUrl;
@end
NSString+Nsstring.m
#import "NSString+NSString.h"
@implementation NSString (NSString)
- (BOOL) isUrl {
if ([self hasPrefix:@"http://"]) {
return YES;
} else {
return NO;
}
}
@end
视图控制器.m
#import "ViewController.h"
#import "NSString+NSString.h"
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSString* string1 = @"http://apple.com/";
NSString* string2 = @"Apple";
if ([string1 isURL]) { // **Here is an error**
NSLog (@"string1 is URL");
}
if ([string2 isURL]) { // **And here**
NSLog (@"string2 is NOT URL");
}
}
我做错了什么?