- (void)viewDidLoad
{
[super viewDidLoad];
User_Id=@"abcd@gmail.com";
NSString *Post=[NSString stringWithFormat:@"email=%@",User_Id];
NSData *PostData = [Post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO];
NSString *PostLengh=[NSString stringWithFormat:@"%d",[Post length]];
NSURL *Url=[NSURL URLWithString:[NSString stringWithFormat:@"%@fetch_all_user_updates.php",ServerPath]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:Url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
[request setValue:PostLengh forHTTPHeaderField:@"Content-Lenght"];
[request setHTTPBody:PostData];
NSData *ReturnData =[NSURLConnection sendSynchronousRequest:request returningResponse:Nil error:Nil];
NSString *Response = [[NSString alloc] initWithData:ReturnData encoding:NSUTF8StringEncoding];
Response = [Response stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSMutableArray *JSON_Array=[Response JSONValue];
// NSlog(@"%@", JSON_Array);
// textfield.text=[[JSON_Array valueforKey:@"email"]objectAtIndex:0];
// load images from database at local host
/*
NSLog(@"%@",[NSString stringWithFormat:@"%@/Images/%@",serverScriptpath,[[jsonarray valueForKey:@"image"]objectAtIndex:0]]);
NSURL *img_url=[NSURL URLWithString:[NSString stringWithFormat:@"%@/Images/%@",
serverScriptpath,[[jsonarray valueForKey:@"image"]objectAtIndex:0]]];
NSURLRequest *request1=[NSURLRequest requestWithURL:img_url];
[Img_profilepic setImageWithURLRequest:request1 placeholderImage:[UIImage imageNamed:@".png"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
}];
*/
if (JSON_Array>0)
{
Array_Image_Name=[JSON_Array valueForKey:@"image_name"];
[Array_Image_Name retain];
}
else
{
UIAlertView *Alert=[[UIAlertView alloc]initWithTitle:@"Failure" message:@"Error To Load Image" delegate:Nil cancelButtonTitle:@"OK" otherButtonTitles:Nil, nil];
[Alert show];
[Alert release];
}
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return Array_Image_Name.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell;
cell=nil;
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
AsyncImageView *Load_Image=[[AsyncImageView alloc]initWithFrame:CGRectMake(20, 10, 280, 100)];
Load_Image.imageURL=[NSURL URLWithString:[NSString stringWithFormat:@"%@/Images/%@",ServerPath,[Array_Image_Name objectAtIndex:indexPath.row]]];
Load_Image.showActivityIndicator=YES;
[cell.contentView addSubview:Load_Image];
return cell;
}