2012-02-07 5 views
0
NSString* username = [[NSUserDefaults standardUserDefaults] stringForKey:@"username_preference"]; 
NSString* accountPassword = [[NSUserDefaults standardUserDefaults] stringForKey:@"password_preference"]; 
NSString* urlString = [NSString stringWithFormat:@"https://%@:%@@testing.com/test.php",username,accountPassword];  
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]; 
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; 
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; 

int status = [httpResponse statusCode]; 
if (!((status >= 200) && (status < 300))) { 
    NSLog(@"Connection failed with status %@", status); 
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; 
} else { 
    NSXMLParser* xmlparser = [[NSXMLParser alloc] initWithData: response]; 
    NSLog(@"at parser %@", xmlparser); 
    [parser setDelegate:self]; 

コードの最終行でエラーが表示され、「パーサーを一時停止に変更する」ことをおすすめします。助けてください!![パーサーsetDelegate:self];

+2

あなたはあなたの質問に答えた答えの横にあるチェックマークをクリックします。 –

答えて

2

あなたのパーサ変数の名前が 'parser'ではなく 'xmlparser'であるためです。

+0

xmlparserに設定しても、同じエラーが表示されます。ところで、XMLParserを使用するには、.mまたは.hクラスに他の.hクラスを実装または含める必要がありますか? – AAB

+1

ええ、多分あなたは "NSXMLParser.h"をインポートする必要があります – Jesper

+0

あなたの助けてくれてありがとう、を含むエラーを取り除いた、今私は別の問題が... "クラスmyclass NSXMLParserDelegateプロトコルを実装していない" ... – AAB

1

parserからxmlparserに変更してください。

+0

xmlparserに設定しても、同じエラーが表示されます。ところで、XMLParserを使用するには、.mまたは.hクラスに他の.hクラスを実装または含める必要がありますか? – AAB