Search code examples
iphoneobjective-cios6

ARC Semantic issue, no visible interface error


I have an error in my implementation file which keeps flagging up for which I cannot seem to fix. I have commented out the error. How can I fix this error?

#import "FilmSearchService.h"


@implementation FilmSearchService
@synthesize searchTerm;
@synthesize delegate;

@synthesize results;
-(void)main {
    NSString *api_key = @"1234";
    NSString *search_term = [searchTerm stringByAddingPercentEscapeUsingEncoding:NSASCIIStringEncoding]; // no visible @ interface for 'NSString' declares the selector 'stringByAddingPercentEscapeUsingEncoding'
    NSString *url = [NSString stringWithFormat:@"http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=%@&q=%@", api_key, search_term];

    NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:url]
                                              cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
    NSData *responseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil];

    if (responseData != nil) {
        NSError *error = nil;
        NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];

        if (error) {
            [delegate serviceFinished:self withError:YES];
        } else {
            results = (NSArray *) [json valueForKey:@"movies"];
            [delegate serviceFinished:self withError:NO];
        }
    } else {
        [delegate serviceFinished:self withError:YES];
    }
}@end

The filmsearchservice header file:

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "ServiceDelegate.h"

@interface FilmSearchService : NSOperation
{
    NSString *searchTerm;
    id<ServiceDelegate> delegate;
    NSArray *results;
}

@property (nonatomic, retain) NSString *searchTerm;
@property (nonatomic, retain) id<ServiceDelegate> delegate;

@property (nonatomic, retain) NSArray *results;


@end

I apologise if it is a relatively simple issue to fix, I'm pretty new to objective c and would appreciate your patience.

Thank you.


Solution

  • The string method is stringByAddingPercentEscape*s*UsingEncoding not stringByAddingPercentEscapeUsingEncoding