didReceiveData is not getting all data

核能气质少年 提交于 2019-12-01 12:39:57

didReceiveData is called a lot of times, while it is receiving data

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [_responseData appendData:data];

}

You have to wait until it finish receiving data

- (void)connectionDidFinishLoading:(NSURLConnection*)connection
{
     [self getDataJSON: _responseData];
}

You can get complete data when connection is finished. NSURLConnection finishes when it's connectionDidFinishLoading: delegate method is called. Try [self getDataJSON: _responseData]; in that method. Good Luck!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!