文字列URLを正しくフォーマットするのに問題があります。必要な出力は次のとおりです。
http://gdata.youtube.com/feeds/api/videos?q=corgi&start-index=1&max-results=50&v=2&fields=entry%5Blink/@rel='http://gdata.youtube.com/schemas/2007%23mobile'%5D
これは私が始めたコードです:
NSString *urlRequest = [NSString stringWithFormat:@"http://gdata.youtube.com/feeds/api/videos?q=corgi&start-index=%u&max-results=%u&v=2&fields=entry[link/@rel='http://gdata.youtube.com/schemas/2007%23mobile']", dataStartIndex, dataIncrements];
NSURL *url = [NSURL URLWithString:urlRequest];
最後に「%23mobile」を文字化けさせ、「20072obile」にします。@記号の前に\を使用してみましたが、うまくいきませんでした。私は何が間違っているのですか?
不思議なことに、次のように2つに分割すると、正しく機能します。
NSString *urlRequest = [NSString stringWithFormat:@"http://gdata.youtube.com/feeds/api/videos?q=corgi&start-index=%u&max-results=%u&v=2&fields=entry", dataStartIndex, dataIncrements];
NSURL *url = [NSURL URLWithString:[urlRequest stringByAppendingString:@"[link/@rel='http://gdata.youtube.com/schemas/2007%23mobile']"]];
引数(dataStartIndex、dataIncrements)なしで実行した場合にも機能します。