Click here to Skip to main content
15,119,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
-(void)requestdata
{
NSDictionary *dict=@{@"entity_id":[[[NSUserDefaults standardUserDefaults] valueForKey:@"logInDetails"] valueForKey:@"entity_id"],
};
[SingletonClass GetDetails:[NSString stringWithFormat:@"http://gsarrow.com/web_service_deals/referral_friend_history.php"] withParams:dict :^(id jsondata, BOOL success){
dispatch_async(dispatch_get_main_queue(), ^{
if (success)
{
NSLog(@"%@",jsondata);
array = [jsondata valueForKey:@"data"];
NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:@"created_at" ascending:YES];
array = [array sortedArrayUsingDescriptors:@[descriptor]];
NSString *oldMonth=@"";
for (NSDictionary *d in array)
{
NSString *dateStr=[d valueForKey:@"created_at"];
NSLog(@"date%@",dateStr);
NSDateFormatter *dformat = [[NSDateFormatter alloc]init];
[dformat setDateFormat:@"MM/dd/yyyy HH:mm:ss"];
NSDate *date1=[[NSDate alloc]init];
date1=[dformat dateFromString:dateStr];
[dformat setDateFormat:@"MMMM"];
NSString *month = [dformat stringFromDate:date1];

What I have tried:

this my code and tried with break points and for(NSDictionary *d in array) from its not executing
Posted
Comments
Mike V Baker 31-Jul-18 11:48am
   
Sounds like your array is empty. What's the result of NSLog jsondata? Is there a 'data' value? Is it an array [ ] or an object { }?
Member 13932190 1-Aug-18 1:00am
   
Array
if ([month isEqualToString:oldMonth]) {

}
else
{
janArray = [[NSMutableArray alloc]init];
febArray = [[NSMutableArray alloc]init];
marArray = [[NSMutableArray alloc]init];
aprArray = [[NSMutableArray alloc]init];
mayArray = [[NSMutableArray alloc]init];
junArray = [[NSMutableArray alloc]init];
julArray = [[NSMutableArray alloc]init];
augArray = [[NSMutableArray alloc]init];
sepArray = [[NSMutableArray alloc]init];
octArray = [[NSMutableArray alloc]init];
novArray = [[NSMutableArray alloc]init];
decArray = [[NSMutableArray alloc]init];
}
oldMonth = month;
[janArray addObject:d];
[dic setValue:janArray forKey:month];
oldMonth = month;
[febArray addObject:d];
[dic setValue:febArray forKey:month];
oldMonth = month;
[marArray addObject:d];
[dic setValue:marArray forKey:month];
oldMonth = month;
[aprArray addObject:d];
[dic setValue:aprArray forKey:month];
oldMonth = month;
[mayArray addObject:d];
[dic setValue:mayArray forKey:month];
oldMonth = month;
[junArray addObject:d];
[dic setValue:junArray forKey:month];
oldMonth = month;
[julArray addObject:d];
[dic setValue:julArray forKey:month];
oldMonth = month;
[augArray addObject:d];
[dic setValue:augArray forKey:month];
oldMonth = month;
[sepArray addObject:d];
[dic setValue:sepArray forKey:month];
oldMonth = month;
[octArray addObject:d];
[dic setValue:octArray forKey:month];
oldMonth = month;
[novArray addObject:d];
[dic setValue:novArray forKey:month];
oldMonth = month;
[decArray addObject:d];
[decArray setValue:d forKey:month];


}
secitonsArray = [dic allKeys];
[self.referalHistoryTable reloadData];
[DejalActivityView removeView];
}
else
{
[DejalActivityView removeView];
UIAlertController *alert=[UIAlertController alertControllerWithTitle:@"Oops" message:@"Connection failed. Please try again later."preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction=[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"Ok Action")style:UIAlertActionStyleCancel handler:^(UIAlertAction *action)
{
}];
[alert addAction:cancelAction];
[self presentViewController:alert animated:YES completion:nil];
}
});
}];
}
@end
Mike V Baker 1-Aug-18 8:29am
   
I don't understand why you put in this code. I was asking what's in the data.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900