This "startloadingdata" method is use for external knowledge only.. here this method start operation with "loadJsonData" Method..
-(void)startloadingdata
{
appdelegate.activityView.hidden=FALSE;
NSOperationQueue *queue = [[NSOperationQueue alloc]init];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(loadJsonData) object:nil];
[queue addOperation:operation];
[operation release];
[queue release];
}
-(void)loadJsonData{
NSURL *jsonURL = [NSURL URLWithString:yourURL];
NSLog(@"url :%@",jsonURL);
NSString *jsonData = [[NSString alloc] initWithContentsOfURL:jsonURL];
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
if(jsonData == nil){
NSLog(@"Data NIL.....");
}
else{
SBJSON *json = [[SBJSON alloc] init];
NSError *error = nil;
dict = [json objectWithString:jsonData error:&error];
[json release];
}
[jsonData release];
if ([dict isKindOfClass:[NSMutableDictionary class]]) {
Result =[dict objectForKey:@"any_dict_key"];
[Result retain];
NSLog(@"Respoonse : %@",Result);
[self performSelectorOnMainThread:@selector(loadDataDone) withObject:nil waitUntilDone:YES];
}
else{
appdelegate.activityView.hidden = TRUE;;
}
}
here Result is object of NSMutableArray
-(void)loadDataDone{
if([Result count]>0)
{
listOfItems=[[NSMutableArray alloc]init];
for(int j=0;j<[latersArray count];j++){
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
for(int i=0;i<[Result count];i++){
NSDictionary *dict = [Result objectAtIndex:i];
if([[[dict objectForKey:@"dap_title"] substringToIndex:1] isEqualToString:[latersArray objectAtIndex:j]]){
[tempArray addObject:dict];
}
}
[listOfItems addObject:tempArray];
[tempArray release];
tempArray=nil;
}
//NSLog(@"listofitem %@",listOfItems);
[tblview reloadData];
}
else{
}
self.view.userInteractionEnabled=TRUE;
self.navigationItem.hidesBackButton=FALSE;
appdelegate.activityView.hidden=TRUE;
}
No comments:
Post a Comment