VoliveTask browse Image And save data and show in first View Controller

browse Image And save data and show in first View Controller :

App link:  https://drive.google.com/open?id=0BwU5Y4Xqfa42TEd4MnFwaHRJZTQ



appdelegate.h

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property NSMutableArray *dAry,*imageAry;


@end

appdelegate.m

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    _dAry=[[NSMutableArray alloc]init];
    _imageAry=[[NSMutableArray alloc]init];
    // Override point for customization after application launch.
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

firstVC.h

#import <UIKit/UIKit.h>

@interface firstViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UITableView *tableV;

@end

firstVC.m

#import "firstViewController.h"
#import "AppDelegate.h"
@interface firstViewController ()

@end

@implementation firstViewController{
    AppDelegate *ad;
}
-(void)viewWillAppear:(BOOL)animated
{
    
    [_tableV reloadData];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableV.delegate=self;
    self.tableV.dataSource=self;
    ad=[[UIApplication sharedApplication]delegate];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [ad.dAry count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *identifier=@"tc";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
    
    if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        
    }
    
    cell.textLabel.text=[ad.dAry objectAtIndex:indexPath.row];
      cell.imageView.image=[ad.imageAry objectAtIndex:indexPath.row];
    
    
    
    return cell;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

secondVC.h

#import <UIKit/UIKit.h>

@interface secondViewController : UIViewController<UIImagePickerControllerDelegate,UINavigationControllerDelegate>
@property (strong, nonatomic) IBOutlet UITextField *dataTF;
- (IBAction)submitAction:(id)sender;
@property NSMutableArray *dataSaveArray,*imageSaveArray;
@property (strong, nonatomic) IBOutlet UIImageView *imageV;
- (IBAction)browseAction:(id)sender;
@end

secondVC.m

#import "secondViewController.h"
#import "AppDelegate.h"
#import "firstViewController.h"
@interface secondViewController ()

@end

@implementation secondViewController{
    AppDelegate *ad;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    ad=[[UIApplication sharedApplication]delegate];
    
    _dataSaveArray=[[NSMutableArray alloc]init];
    _imageSaveArray=[[NSMutableArray alloc]init];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)submitAction:(id)sender {
   [ad.dAry addObject:_dataTF.text];

    [ad.imageAry addObject:_imageV.image];
  //  [_dataSaveArray addObject:_dataTF.text];
  //  [_imageSaveArray addObject:_imageV.image];
    NSLog(@"%@",_dataSaveArray);
  //  ad.dAry=_dataSaveArray;
 //   ad.imageAry=_imageSaveArray;


    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)browseAction:(id)sender {
    UIImagePickerController *pickerController = [[UIImagePickerController alloc]init];
    pickerController.delegate = self;
    [self presentViewController:pickerController animated:YES completion:nil];
    
}
- (void) imagePickerController:(UIImagePickerController *)picker
         didFinishPickingImage:(UIImage *)image
                   editingInfo:(NSDictionary *)editingInfo
{
    self.imageV.image = image;
   [self dismissViewControllerAnimated:YES completion:nil];
}

@end
Previous
Next Post »