2014-06-10 58 views
0

this tutorial我wrotte驗證碼:無法從URL目標獲取的NSDataÇ

NSData* json = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://api.fessor.da.stanids.office/homework/index/?rp[token]=app&rp[workspace]=parent&child_id=22066&type=parent&start_date=2014-05-01&end_date=2014-05-01"]]; 

NSLog([NSString stringWithFormat:@"%@",json]); 

,但我得到零當我登錄時的結果。 有人可以告訴我,如果這個教程是壞的,或者我在某處做錯了什麼?

P.S.我在viewDidLoad中調用這段代碼。

+0

首先嚐試執行在瀏覽器中的請求。它在瀏覽器中也不工作,所以它不能在代碼中工作。 –

回答

1
NSData* json = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://api.fessor.da.stanids.office/homework/index/?rp[token]=app&rp[workspace]=parent&child_id=22066&type=parent&start_date=2014-05-01&end_date=2014-05-01"]]; 

NSDictionary * dictData = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; 

嘗試用這個..