Apple のドキュメントのコードを使用して、HTTP 通信を行っています。URL には正常に接続できますが、サーバーからデータを受信できませんでした。
// create the request
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://..."]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
// Create the NSMutableData that will hold
// the received data
// receivedData is declared as a method instance elsewhere
NSMutableData *receivedData=[[NSMutableData data] retain];
} else {
// inform the user that the download could not be made
}
理由は次のとおりです。
receivedData
私はアクション自体で宣言します。注釈には、別の場所で宣言する必要があると書かれています。どこに申告すればいいですか?コントローラーのプロパティとして宣言する必要がありますか?[[NSMutableData data] retain]
の外部にあるため、URL をどのように見つけることができますif{}
か?