2012-02-07 48 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

您單擊您找到的答案旁邊的複選標記以回答您的問題。 – 2012-02-07 10:22:29

回答

2

那麼,是不是因爲你的分析器變量被命名爲「xmlparser」而不是「分析器」?

+0

即使我將它設置爲xmlparser,它也會顯示相同的錯誤。順便說一句,我們是否必須在我們的.m或.h類中實現或包含一些其他.h類以使用XMLParser? – AAB 2012-02-07 09:26:45

+1

是的,也許你必須導入「NSXMLParser.h」 – Jesper 2012-02-07 09:28:41

+0

感謝您的幫助,包括刪除錯誤,現在我有另一個問題......它說「類myclass不實施NSXMLParserDelegate協議」。 ... – AAB 2012-02-07 09:38:23

1

更改parserxmlparser

+0

即使我將它設置爲xmlparser,它也會顯示相同的錯誤。順便說一句,我們是否必須在我們的.m或.h類中實現或包含一些其他.h類以使用XMLParser? – AAB 2012-02-07 09:27:24