ユーチューブで検索してみました。このコードは、英語の文字で正常に機能します。しかし、ö、ü、ş などの英語以外の文字を入力しようとすると、null が返されます。
NSString *kStrJsonURL = [NSString stringWithFormat:@"http://suggestqueries.google.com/complete/search?hl=en&ds=yt&client=youtube&hjson=t&cp=1&q=%@&key=API_KEY&format=5&alt=jsonc&callback=?", self.searchField.text];
NSURL *url = [NSURL URLWithString:kStrJsonURL];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id getJSON) {
_JSON = getJSON;
NSLog(@"%@", _JSON);
} failure:nil];
[operation start];
このようにURLをエンコードしようとしましたが、うまくいきません..
[self.searchField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]