我的项目中有一个连接类。我想在很多工作中使用这个类。当我尝试调用此类的函数时出现以下错误:没有可见的@interface 声明选择器错误
核心连接.h
@interface coreConnection:NSArray
{
NSData *returnData;
}
-(NSArray*)getData;
@end
核心连接.m
#import "coreConnection.h"
@implementation coreConnection
-(NSArray*)getData:(NSString*)link
{
NSOperationQueue *apiCallsQueue = [[NSOperationQueue alloc] init];
NSURL *URL = [NSURL URLWithString:link];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
[NSURLConnection sendAsynchronousRequest:request queue:apiCallsQueue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
returnData = data;
});
}];
return [NSJSONSerialization JSONObjectWithData:returnData options:nil error:nil];
}
@end
视图控制器.m
#import "coreConnection.h"
- (void)viewDidLoad
{
[[self headlineCollectionView]setDelegate:self];
[[self headlineCollectionView]setDataSource:self];
[self.headlineCollectionView registerNib:[UINib nibWithNibName:@"HeadLineCell" bundle:nil] forCellWithReuseIdentifier:@"CELL"];
coreConnection speed=[[coreConnection alloc] init];;
headline = [speed getData:@"string"];
[self.headlineCollectionView reloadData];
[super viewDidLoad];
}