How to array data reload in UITableView? I use a web services and fetch data stored in a array. I got a data and print on consol but same array can't reload in TableView.
Please help me how to show data on table view i trying to many times but can't show data.
JSON
{
"status": {
"event": [
{
"event_id": "28",
"event_name": "Event name",
"event_title": "svsav",
"img": "http:\/\/edutimeapp.com\/toshow\/chamber-of-commerc\/uploads\/1461402793-Vtcg8pRB.jpg",
"event_date": "2016-04-05",
"event_time": "12:00",
"event_detail": "svsa"
},
viewcontroller
#import "ViewController.h"
#import "celltable.h"
#interface ViewController ()
{
NSArray*name;
}
#end
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableview setAllowsMultipleSelection:YES];
NSURLRequest *req=[[NSURLRequest alloc]initWithURL:[NSURL URLWithString:#"http://edutimeapp.com/toshow/chamber-of-commerc/ws/fetch_event.php"]];
response =[[NSMutableData alloc]init];
[NSURLConnection connectionWithRequest:req delegate:self];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[response appendData:data];
NSLog(#"error receving data %#",response);
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSError *error;
NSLog(#"Error in receiving data %#",error);
NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
NSLog(#"response data %#",son);
NSError *jsonParsingError = nil;
NSDictionary *retrievedJTransD = [NSJSONSerialization JSONObjectWithData:response options:0 error:&jsonParsingError];
NSArray* retrievedJTrans = retrievedJTransD[#"status"][#"event"];
name = [retrievedJTrans valueForKey:#"event_name"];
NSLog(#"success %#", name);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [name count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(#"tableview cell");
celltable *cell = [tableView dequeueReusableCellWithIdentifier:#"ht"];
if (cell==nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"Cell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.date.text=[NSString stringWithFormat:#"%#",[name objectAtIndex:indexPath.row]];
return cell;
}
Your mistake is cannot reload the tableview, next you did not correctly set the array values, Use this below code,
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSError *error;
NSLog(#"Error in receiving data %#",error);
NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
NSLog(#"response data %#",son);
NSError *jsonParsingError = nil;
NSDictionary *retrievedJTransD = [NSJSONSerialization JSONObjectWithData:response options:0 error:&jsonParsingError];
NSArray* retrievedJTrans = retrievedJTransD[#"status"][#"event"];
//you are wrong in name array change it.
name = retrievedJTrans;
NSLog(#"success %#", name);
[self.tableview reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [name count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(#"tableview cell");
celltable *cell = [tableView dequeueReusableCellWithIdentifier:#"ht"];
if (cell==nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"Cell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.date.text=[NSString stringWithFormat:#"%#",[[name objectAtIndex:indexPath.row] valueForKey:#"event_name"]];
return cell;
}
hope its helpful
After You get response from WS
dispatch_async(dispatch_get_main_queue(), ^{
[self.yourTableview reloadData];
});
Always remember that when you need reload tableview and you are using WS Call or any other block operations reload it in main thread
Related
I want to create a message conversation screen.I have two arrays, first is web_array and the second is local_array. First, I have one UITableViewCell in one UILabel, and one UITextField, and one UIButton. In the textfield, write any text and it will print on UITableViewCell label. TextField text is stored in a one array (local_array). (application run time local_array is empty).
And second array (web_array), web_array is stored in a web service get data, I want to web_array count on UITableViewCell label after local_array count in same label.
web_array data counting is over after just down local_array data counting start.
My english is very bad and i can't explain proper. seriously i'm so tired please help me and guide.
ViewController
#import "Chat_ViewController.h"
#import "chatview_Cell.h"
#interface Chat_ViewController () <UITableViewDataSource,UITableViewDelegate>
{
NSArray*web_array;
NSMutableArray*Local_array;
}
#end
#implementation Chat_ViewController
- (void)viewDidLoad {
[super viewDidLoad];
Local_array=[[NSMutableArray alloc]init];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:#"MYURL"]];
//create the Method "GET" or "POST"
[request setHTTPMethod:#"POST"];
//Pass The String to server(YOU SHOULD GIVE YOUR PARAMETERS INSTEAD OF MY PARAMETERS)
NSString *userUpdate =[NSString stringWithFormat:#"senderid=%#&recid=%#&",_chat_myuid.text,_chat_uid.text, nil];
//Check The Value what we passed
NSLog(#"the data Details is =%#", userUpdate);
//Convert the String to Data
NSData *data1 = [userUpdate dataUsingEncoding:NSUTF8StringEncoding];
//Apply the data to the body
[request setHTTPBody:data1];
//Create the response and Error
NSError *err;
NSURLResponse *response;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&err];
NSString *resSrt = [[NSString alloc]initWithData:responseData encoding:NSASCIIStringEncoding];
//This is for Response
NSLog(#"got response==%#", resSrt);
NSArray *results = [json objectForKey:#"status"];
web_array = [results valueForKey:#"message"];
NSLog(#"your message %#",web_array);
//This is for Response
NSLog(#"got response==%#", resSrt);
if(resSrt)
{
NSLog(#"got response");
}
else
{
NSLog(#"faield to connect");
}
}
- (IBAction)send:(id)sender
{
NSString *textNameToAdd = self.mymsg.text; //mymsg is UITextField outlet
[Local_array addObject:textNameToAdd];
[self.table_view reloadData];
}
//TABLEVIEWCELL Code
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if ([Local_array count] > 0 && web_array.count>0)
{
return [Local_array count];
}
else
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
chatview_Cell *cell = [tableView dequeueReusableCellWithIdentifier:#"ht"];
if (cell==nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"Cell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
if (Local_array.count > 0 && web_array.count>0)
{
cell.other_msg.text=[NSString stringWithFormat:#"%#",[Local_array objectAtIndex:indexPath.row]];
}
cell.other_msg.text=[NSString stringWithFormat:#"%#",[web_array objectAtIndex:indexPath.row]];
return cell;
}
Hello I have working simple tableview json parsing codes. But i want to do reload tableview in background everytime i added dispatch_sync codes but don't working my codes under.
NSArray * jsonArray;
NSMutableArray * array1;
- (void)viewDidLoad {
[super viewDidLoad];
NSURL * url = [NSURL URLWithString:#"http://bla.com/test2.json"];
NSURLRequest * urlReq = [NSURLRequest requestWithURL:url];
NSError * error;
NSData * data = [NSURLConnection sendSynchronousRequest:urlReq returningResponse:nil error:&error];
NSDictionary * jsonDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
NSLog(#"%#",jsonDict);
jsonArray = [jsonDict objectForKey:#"worldpopulation"];
NSLog(#"%#",jsonArray);
array1 =[[NSMutableArray alloc]init];
}
- (void)main
{
dispatch_sync(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return jsonArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellid=#"CustomCell";
CustomTableViewCell *cell=(CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid];;
if(cell==nil)
{
cell=[[CustomTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellid];
}
for ( NSDictionary * dict in jsonArray) {
NSString * country = [dict objectForKey:#"country"];
[array1 addObject:country];
}
cell.nameLabel.text= [array1 objectAtIndex:indexPath.row];
return cell;
}
Main.m
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
I added only needed codes . I need to fix it .
Thanks for your help !
First, performing synchronous network operations on the main thread is a bad idea - it will make your app UI 'freeze' until the operation completes, which in the case of a slow (or no) network could be a long time.
Secondly, you should move the loading code into its own function that you call from viewDidLoad - this way you can easily call it again if you want to reload the data.
Thirdly, your cellForRowAtIndexPath is iterating your entire jsonArray for each cell to no purpose.
Finally, NSURLConnection is deprecated in iOS 9 so you should migrate to NSURLSession if you are targeting iOS7 and later (if you want to run on iOS prior to iOS 7 then you will need to keep using NSURLConnection)
I would suggest the following:
#interface MyViewController () <UITableViewDelegate,UITableViewDataSource>
#property (strong,nonatomic) NSArray *jsonArray;
#end
#implementation MyViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.jsonArray=[NSArray new];
[self loadJSON];
}
-(void)loadJSON {
NSURL * url = [NSURL URLWithString:#"http://bla.com/test2.json"];
NSURLSession *session=[NSURLSession sharedSession];
[session dataTaskWithRequest:url completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error!=nil) {
NSLog(#"Something went wrong:%#",error);
} else {
NSError *jsonError;
NSDictionary * jsonDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonEerror];
if (jsonError != nil) {
NSLog(#"JSON isn't right:%#",jsonError);
} else {
self.jsonArray = jsonDict[#"worldpopulation"];
dispatch_async(dispatch_get_main_queue(),^{
[self.tableview reloadData];
});
}
}];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.jsonArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellid=#"CustomCell";
CustomTableViewCell *cell=(CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid forIndexPath:indexPath];;
NSDictionary *entryDict=self.jsonArray[indexPath.row];
NSString *countryName=entryDict[#"country"];
cell.nameLabel.text= countryName;
return cell;
}
I’m using searchbarcontroller for filter the tableview data, everything is working fine but the problem is same data is repeating on filter while using searchbarcontroller tableview.
Like: suppose if List of alphabets is showing on the tableview (A,B,C,D) tableViewCells then when i used searchbarcontroller on this tableview then (tableView == self.searchDisplayController.searchResultsTableView) is shows the data in repeating way
Like: if i'm search for A the searchResultTableView is showing (A,A,A,A,A,A) on tableViewCells.
But on the normal tableview data is showing normally without repeating the data.
Any one please suggest me where is the actual problem in my code.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.xyz.com/work.php]];
responseDataSP=[[NSMutableData alloc]init];
urlConnectionSP=[[NSURLConnection alloc]initWithRequest:request delegate:self];
NSLog(#"nsurl my %#",urlConnectionSP);
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
NSLog(#"Error");
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
[responseDataSP setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
[responseDataSP appendData:data];
NSLog(#"%#",responseDataSP);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSError *error=nil;
NSDictionary *dicSP=[NSJSONSerialization JSONObjectWithData:responseDataSP options:NSJSONReadingMutableContainers error:&error];
self.totalDataSP=[dicSP objectForKey:#"data"];
NSLog(#"%#",_totalDataSP);
totalTitleSP=[[NSMutableArray alloc]init];
totalImageSP=[[NSMutableArray alloc]init];
totalIdWalaSP=[[NSMutableArray alloc]init];
[_tableView reloadData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.searchDisplayController.searchResultsTableView) {
return [searchResults count];
} else {
return [_totalDataSP count];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 80;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = #"SkillsTableCell";
SkillsTableCell *cell = (SkillsTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"SkillsTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
NSDictionary *items=nil;
NSArray *titleSP;
NSArray *imageSP;
NSArray *idwalaSP;
for(int i=0;i<[_totalDataSP count];i++){
// NSLog(#"the _totalDataSP is %#",[_totalDataSP count]);
items=[_totalDataSP objectAtIndex:i];
titleSP=[items objectForKey:#"first_name"];
[totalTitleSP addObject:titleSP];
imageSP=[items objectForKey:#"profile_pic"];
[totalImageSP addObject:imageSP];
idwalaSP=[items objectForKey:#"id"];
[totalIdWalaSP addObject:idwalaSP];
category_id = [items objectForKey:#"id"];
NSLog(#"id value is %#",category_id);
}
dispatch_async(dispatch_get_main_queue(), ^{
if (tableView == self.searchDisplayController.searchResultsTableView) {
cell.textLabel.text = [searchResults objectAtIndex:indexPath.row];
} else {
cell.nameLabel.text=[totalTitleSP objectAtIndex:indexPath.row];
}
//For Image
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[totalImageSP objectAtIndex:indexPath.row]]];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if (data) {
cell.thumbnailImageView.image = [UIImage imageWithData:data];
}
}];
[cell setNeedsDisplay];
});
return cell;
}
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
NSPredicate *resultPredicate = [NSPredicate
predicateWithFormat:#"SELF contains[cd] %#",
searchText];
searchResults = [totalTitleSP filteredArrayUsingPredicate:resultPredicate];
}
#pragma mark - UISearchDisplayController delegate methods
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller
shouldReloadTableForSearchString:(NSString *)searchString
{
[self filterContentForSearchText:searchString
scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
objectAtIndex:[self.searchDisplayController.searchBar
selectedScopeButtonIndex]]];
return YES;
}
Thanks In Advance.
Using Predicates with Arrays
NSPredicate *sPredicate = [NSPredicate predicateWithFormat:#"SELF contains[c] 'e'"];
[array filterUsingPredicate:sPredicate];
or
It display desire order without duplicates
NSArray *beginArray = [filteredArray filteredArrayUsingPredicate:
[NSPredicate predicateWithFormat:
#"self BEGINSWITH[cd] %#", searchText]];
NSArray *anyArray = [filteredArray filteredArrayUsingPredicate:
[NSPredicate predicateWithFormat:
#"self CONTAINS[cd] %#", searchText]];
NSMutableArray *resultArray = [NSMutableArray arrayWithArray:beginArray];
for (id obj in anyArray) {
if (![resultArray containsObject:id]) {
[resultArray addObject:id];
}
}
filteredArray = resultArray;
I want to create an App which parses the picture Links of a Facebook page and shows them in an iOS app (display them in tableView). But after I parsed the JSON file and added them to an array which should be downloaded nothing is displayed.
Here's the code:
- (void)viewDidLoad
{
self.edgesForExtendedLayout = UIRectEdgeNone;
[super viewDidLoad];
items = [[NSMutableArray alloc] init];
NSURL *url = [NSURL URLWithString:#"https://graph.facebook.com/HuppFotografie/photos/uploaded/?fields=id,name,picture"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
connection = [NSURLConnection connectionWithRequest:request delegate:self];
if (connection) {
webData = [[NSMutableData alloc]init];
}
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[webData setLength:0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(#"fail with error");
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSDictionary *allDataDictionary = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];
NSArray *arrayOfData = [allDataDictionary objectForKey:#"data"];
for (NSDictionary *dicton in arrayOfData) {
NSString *picture = [dicton objectForKey:#"picture"];
[items addObject:picture];
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 250.0;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [items count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = #"MyImageCell";
ImageCell *cell = (ImageCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.backgroundColor = [UIColor clearColor];
if (cell == nil) {
NSArray* topLevelObjects = [[NSBundle mainBundle] loadNibNamed:#"ImageCell" owner:self options:nil];
for (id currentObject in topLevelObjects) {
if ([currentObject isKindOfClass:[UITableViewCell class]]) {
cell = (ImageCell *)currentObject;
break;
}
}
}
// Here we use the new provided setImageWithURL: method to load the web image
[cell.imageView setImageWithURL:[NSURL URLWithString:[items objectAtIndex:indexPath.row]] placeholderImage:[UIImage imageNamed:#"Placeholder.jpg"]];
cell.imageSource.text = [items objectAtIndex:indexPath.row];
return cell;
}
I really don't get why. I'm sorry if this question is stupid but I am coding just as a hobby and have not that great experience.
In fact your connection is asynchronous, so you just need to reload your table view programmatically to display loaded images:
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSDictionary *allDataDictionary = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];
NSArray *arrayOfData = [allDataDictionary objectForKey:#"data"];
for (NSDictionary *dicton in arrayOfData) {
NSString *picture = [dicton objectForKey:#"picture"];
[items addObject:picture];
}
// Just add this line, in order to force reload when all your data is arrived
[self.tableView reloadData];
}
I have json like this (have dictionary and array).
I want draw all json into UItableviewcell, but its not draw there
{ data: [
{
featured: true,
price: {
currency: "IDR",
amount: 5557679,
formatted: "Rp5.558.000"
},
] }
and this is my viewcontroller.h file
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController{
IBOutlet UITableView *mainTableView;
NSURL *URL;
NSDictionary *Deals;
NSArray *Deals_array;
NSMutableData *data;
}
#end
and this is my .m file
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.title=#"SOme Apps";
[UIApplication sharedApplication].networkActivityIndicatorVisible=YES;
URL = [NSURL URLWithString:[NSString stringWithFormat:#"http://someurl.com"]];
NSURLRequest *request=[NSURLRequest requestWithURL:URL];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
/*dispatch_async(kBgQueue, ^{
NSData* data = [NSData dataWithContentsOfURL: URL];
[self performSelectorOnMainThread:#selector(fetchedData:) withObject:data waitUntilDone:YES];
});*/
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
data=[[NSMutableData alloc] init];
NSLog(#"%#",data);
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)theData
{
[data appendData:theData];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
NSError* error;
Deals= [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
Deals_array = [Deals objectForKey:#"data"]; //2
NSDictionary* loan = [Deals_array objectAtIndex:0];
NSString *test=[loan objectForKey:#"featured"];
NSLog(#"%#",test);
[mainTableView reloadData];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
NSLog(#"Error");
}
////set minimum section oftableview
-(int)numberOfTableviewSection : (UITableView *) tableView
{
return 1;
}
////set length uitableview
-(int) tableView :(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [Deals_array count];
}
///declaring uitableview
-(UITableViewCell *)tableView :(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:#"MainCell"];
if (cell==nil){
cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"MainCell"];
}
cell.textLabel.text=[[Deals_array objectAtIndex:indexPath.row] objectForKey:#"featured"];
return cell;
}
#end
but its not draw the objectkey #test, can someone help me why?
Try doing the allocation
Deals_array = [[NSArray alloc] initWithArray:[Deals objectForKey:#"data"]];