Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>//NSURL CONNECTION WITH JSON PARSING:</strong></p> <p><strong><a href="https://www.dropbox.com/s/ubmaulkdhbdqha1/ViewController.m" rel="nofollow">https://www.dropbox.com/s/ubmaulkdhbdqha1/ViewController.m</a></strong></p> <pre><code>ViewController.h @interface ViewController : UIViewController&lt;UITableViewDelegate,UITableViewDataSource&gt; { IBOutlet UITableView *tableView1; NSArray *practice_ArrayForDisplayingEx; NSMutableArray *arrRespone; NSMutableData *responseData; NSMutableDictionary *resultsDictionary; NSURLConnection *urlConnection; } @property(nonatomic,strong) IBOutlet UITableView *tableView1; @property (nonatomic, strong) NSMutableData *responseData; @end </code></pre> <p><strong>ViewController.m</strong></p> <pre><code>- (void)viewDidLoad { arrRespone=[NSMutableArray new]; self.responseData = [NSMutableData data]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.indiaglitz.com/json/vod_menu_init.asp"]]; urlConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self]; [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [self.responseData appendData:data]; } - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [self.responseData setLength:0]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"didFailWithError"); // NSLog([NSString stringWithFormat:@"Connection failed: %@", [error description]]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"connectionDidFinishLoading"); NSLog(@"Succeeded! Received %d bytes of data",[self.responseData length]); // convert to JSON NSError *myError = nil; resultsDictionary = [NSJSONSerialization JSONObjectWithData:self.responseData options:NSJSONReadingMutableLeaves error:&amp;myError]; NSDictionary *arrDetails=[[resultsDictionary objectForKey:@"menu"] objectAtIndex:0] ; NSDictionary *genr=[[arrDetails valueForKey:@"categories"] objectAtIndex:0]; NSLog(@"array detailsarray ====&gt;%@",arrDetails); NSLog( @"genreee arrray==%@",genr); //NSLog(@"genrvalueeee -----%@",[genr valueForKey:@"genre"]); NSLog(@"counttttt===%d",[[genr valueForKey:@"genre" ] count]); NSLog(@"genre objectatindex==%@",[genr valueForKey:@"cliptype"]); for (int i=0;i&lt;[[genr valueForKey:@"genre" ] count];i++) { NSDictionary *strDetails=[[genr valueForKey:@"genre"] objectAtIndex:i]; NSString *str=[strDetails valueForKey:@"gname"]; NSLog(@"First string details===&gt;%@",str); [arrRespone addObject:str]; NSLog(@"response ====&gt;%@",arrRespone); } [tableView1 reloadData]; } #pragma mark Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { NSLog(@"numberOfSectionsInTableView"); return 1; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 45; NSLog(@"heightForRowAtIndexPath"); } // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSLog(@"numberOfRowsInSection"); return [arrRespone count]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"inside tableview"); static NSString *CellIdentifier = @"TableCell"; //TableCell *cell = (TableCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier]; } // cell.textLabel.text=[arrRespone objectAtIndex:indexPath.row]; NSLog(@"cellvalue:%@",cell.textLabel.text); NSLog(@"inside numberofRowsInsection"); // Configure the cell... cell.textLabel.text = [arrRespone objectAtIndex:indexPath.row]; return cell; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload