iosから安全なURLにアクセスしようとしています。基本的にurlはユーザーにUsernameとPasswordを入力するよう促します。 iosからユーザー名とパスワードを送信するにはどうすればよいですか?ここでiosから保護されたURLにアクセスする方法
マイコード は、私がここでJSONパーサーの
- (NSString *)stringWithUrl:(NSURL *)url{
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReturnCacheDataElseLoad
timeoutInterval:30];
// Fetch the JSON response
NSData *urlData;
NSURLResponse *response;
NSError *error;
// Make synchronous request
urlData = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&response
error:&error];
// Construct a String around the Data from the response
return [[[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding] autorelease];}
- (id) objectWithUrl:(NSURL *)url{
SBJsonParser *jsonParser = [[[SBJsonParser alloc]init] autorelease];
NSString *jsonString = [self stringWithUrl:url];
// Parse the JSON into an Object
return [jsonParser objectWithString:jsonString error:nil]; }
にアクセスするために使用している方法である私は私の辞書にJSONのキーを取得していたコードの一部です。
- (NSDictionary *) downloadFeed {
id response = [self objectWithUrl:[NSURL URLWithString:@"http://mysite.com/Services/Secure.svc/GetList?id=2127"]];
NSDictionary *feed = (NSDictionary *)response;
return feed; }
誰かがこのURLにユーザー名とパスワードを渡すことができますか?
どのような意味でプロンプトが表示されますか?ウェブサイトのログインフォーム、[基本的なHTTP認証](http://en.wikipedia.org/wiki/Basic_access_authentication)? – Alex
基本的なHTTP認証、より明確な画像を得るためにコードを更新しました! – HardCode
「http:// user:[email protected]/...」 –