【发布时间】:2011-07-14 12:23:58
【问题描述】:
我有一个输出以下 JSON 的 php 文件:
[{"0":"5","questionId":"5","1":"Morning Heart Rate","question":"Morning Heart Rate","2":"5","questionNumber":"5","3":"1","sectionId":"1"},{"0":"4","questionId":"4","1":"Evening Urine Colour","question":"Evening Urine Colour","2":"4","questionNumber":"4","3":"1","sectionId":"1"},{"0":"3","questionId":"3","1":"Evening Bodyweight","question":"Evening Bodyweight","2":"3","questionNumber":"3","3":"1","sectionId":"1"},{"0":"2","questionId":"2","1":"Morning Urine Colour","question":"Morning Urine Colour","2":"2","questionNumber":"2","3":"1","sectionId":"1"},{"0":"1","questionId":"1","1":"Morning Bodyweight","question":"Morning Bodyweight","2":"1","questionNumber":"1","3":"1","sectionId":"1"},{"0":"6","questionId":"6","1":"Time of Month (TOM)","question":"Time of Month (TOM)","2":"6","questionNumber":"6","3":"1","sectionId":"1"}]
这可以在以下链接中看到:
http://dev.speechlink.co.uk/David/get_questionstest.php
我在Objective C中使用JSONKit作为解码JSON的框架。下面的方法用于与php进行通信:
//方法
+(void)getQuestions:(NSString*)sectionId{
NSString* url = @"http://dev.speechlink.co.uk/David/get_questions.php";
NSURL *link = [NSURL URLWithString:url];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:link];
[request setPostValue:sectionId forKey:@"section"];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestFinished:)];
[request startAsynchronous];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
//NSString *response = [request responseString];
NSLog(@"hello"); //never prints
}
从未调用过代表...谁能解释一下?
【问题讨论】:
标签: php iphone objective-c xcode asihttprequest