|
|
|
Xcode - จะทำ asynchronous ใน NSURLConnection ให้รอจนเสร็จ ช่วยดู Code ให้ทีครับ |
|
|
|
|
|
|
|
ทำที่ connectionDidFinishLoading ครับ เช่น
Code (Objective-C)
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
if(receivedData)
{
//NSLog(@"%@",receivedData);
//NSString *dataString = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding];
//NSLog(@"%@",dataString);
id jsonObjects = [NSJSONSerialization JSONObjectWithData:receivedData options:NSJSONReadingMutableContainers error:nil];
// values in foreach loop
for (NSDictionary *dataDict in jsonObjects) {
NSString *strGalleryID = [dataDict objectForKey:@"GalleryID"];
NSString *strName = [dataDict objectForKey:@"Name"];
NSString *strTitleName = [dataDict objectForKey:@"TitleName"];
NSString *strThumbnail = [dataDict objectForKey:@"Thumbnail"];
dict = [NSDictionary dictionaryWithObjectsAndKeys:
strGalleryID, galleryid,
strName, name,
strTitleName, titlename,
strThumbnail, thumbnail,
nil];
[myObject addObject:dict];
}
[myTable reloadData];
}
// release the connection, and the data object
[connection release];
[receivedData release];
}
iOS/iPhone NSURLConnection and PHP MySQL / JSON (TableView,UITableView)
|
|
|
|
|
Date :
2015-03-08 17:15:29 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|