Can you have a look at this code please
#import "ViewController.h"
#import "DataService.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITableView *TableView;
@property (strong, nonatomic) DataService *Service;
@property (nonatomic, strong) MSTable *table;
//@property (nonatomic, strong) MSClient *client;
@property (nonatomic, strong) NSMutableArray *items;
@end
@implementation ViewController
@synthesize Service;
@synthesize rowitems;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.client = [MSClient clientWithApplicationURLString:@"https://outnight-mobile.azure-mobile.net/"
applicationKey:@"okYeRGfBagYrsbkaqWIRObeDtktjkF10"];
self.table = [self.client tableWithName:@"notifications"];
self.rowitems = [[NSMutableArray alloc] init];
MSQuery *query = [self.table query];
query.fetchLimit = 5;
[query readWithCompletion:^(NSArray *items, NSInteger totalCount, NSError *error)
{
//add the items to our local cop
self.rowitems = [items mutableCopy];
}];
[self.TableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
//return 5;
NSLog(@"%d",[self.rowitems count]);
return 5;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
cell.textLabel.text = @"fool";
return cell;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
This UTTableView should go to the database (which is does fine) and it should retrieve back the first 5 rows and it does. but when I
numberofrowsinsection does not see the amount of 5 when i do a array count ?? This is driving me crazy, what am I doing wrong ?
thanks