Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSLog(@"%@",NSStringFromSelector(_cmd));
- MyStoreCell *cell = [self.myTableView dequeueReusableCellWithIdentifier: self.identifier];
- MyStore *myStore = [self.stores objectAtIndex: indexPath.row];
- [self downloadAndSetImageForStore: myStore];
- cell.storeName.text = myStore.name;
- cell.label1.text = myStore.address;
- cell.label2.text = myStore.phone;
- cell.label3.text = @"Ask what to enter here :)";
- cell.imgView.image = myStore.logo;
- return cell;
- }
- - (void) downloadAndSetImageForStore: (MyStore *) myStore
- {
- NSLog(@"%@",NSStringFromSelector(_cmd));
- NSURL *url = [NSURL URLWithString: myStore.url];
- NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: url];
- NSString *username = [NSString stringWithFormat: @"xtrmail@gmail.com"];
- NSString *password = [NSString stringWithFormat: @"pass123"];
- NSString *str = [NSString stringWithFormat: @"id=%@&username=%@&password=%@",myStore.storeID,username, password];
- NSData *data = [str dataUsingEncoding: NSUTF8StringEncoding];
- NSLog(@"%@",str);
- [request setHTTPMethod: @"POST"];
- [request setHTTPBody: data];
- [NSURLConnection sendAsynchronousRequest: request queue: self.myQueue completionHandler: ^(NSURLResponse *response, NSData *data, NSError *error)
- {
- NSLog(@"completionHandler execution");
- if(error != nil)
- {
- NSLog(@"error response: %@",error.localizedDescription);
- dispatch_async(dispatch_get_main_queue(), ^{
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"ERROR" message: error.localizedDescription delegate: self cancelButtonTitle: @"OK" otherButtonTitles: nil];
- [alert show];
- [alert release];
- });
- }
- else if(error == nil)
- {
- myStore.logo = [UIImage imageWithData: data];
- NSLog(@"%@",myStore.logo);
- dispatch_async(dispatch_get_main_queue(), ^{
- [self.myTableView reloadData];
- });
- }
- }];
- }
Add Comment
Please, Sign In to add comment