I have a connection class in my project. I want to use this class in for a lot of works. When I tried to call this class's function getting following error : No visible @interface declares the selector error
coreConnection.h
@interface coreConnection:NSArray
{
NSData *returnData;
}
-(NSArray*)getData;
@end
coreConnection.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
viewController.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];
}
Hehe the problem is pretty simple your method in implementation and used in code is
-(NSArray*)getData:(NSString*)link
not
-(NSArray*)getData;
which is declared in .h file so make the declaration as
-(NSArray*)getData:(NSString*)link;
in .h file
EDIT
You also missed *
in allocing the object
Use
coreConnection *speed=[[coreConnection alloc] init];;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With