UPDATE Just resetted al Simulators Data and now it works fine.
I'll appreciate any help :)
My app writes data to a Data.plist file in a subfolder of Documents. I added an NSLog to find out the path so I can check it. I finded and the plist is good. I tried it in a iPad Air. Another page has a "Load" button for loading the plist data and placing it in a textfield. In the iPad Air the info is loaded totally fine.
BUT! I tried it in an iPad 2. And the 2 strings are not loaded. The keys and objects are:
proyectName string example
revisarCimiento bool 1
tipoCodigoEsfuerzosAdmisibles string Canada
tipoUnidadMamposteria string Block
mamposteriaConfinada bool 0
When the data is loaded, the proyect name doesn't depend on the plist. The bools are fine but the other 2 strings are not loaded.
Here is the code
.h
//
// factoresCombinacionesCargaViewController.h
// calcMurosLosas
//
// Created by Brian Matus on 15/12/14.
// Copyright (c) 2014 Matus. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface factoresCombinacionesCargaViewController : UIViewController <UITextFieldDelegate>
- (IBAction)loadData:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *proyectName;
@property (weak, nonatomic) IBOutlet UITextField *levels;
@property (weak, nonatomic) IBOutlet UITextField *revisarCimiento;
@property (weak, nonatomic) IBOutlet UITextField *tipoCodigoEsfuerzosAdmisibles;
@property (weak, nonatomic) IBOutlet UITextField *tipoUnidadMamposteria;
@property (weak, nonatomic) IBOutlet UITextField *mamposteriaConfinada;
+ (void)proyectPath:(NSString *)theString;
@end
.m
#import "factoresCombinacionesCargaViewController.h"
#import "infoGeneralViewController.h"
@interface factoresCombinacionesCargaViewController ()
@end
NSString *proyectPath;
@implementation factoresCombinacionesCargaViewController
- (void)viewDidLoad {
[super viewDidLoad];
// 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)loadData:(id)sender {
[infoGeneralViewController getProyectNameFromPlist]; //This calls a method that returns a string tho the proyectPath method below.
[self performSelector:@selector(setLabels) withObject:nil afterDelay:0.1];
}
+ (void)proyectPath:(NSString *)theString {
proyectPath = theString;
}
-(void)setLabels {
NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithContentsOfFile:[proyectPath stringByAppendingPathComponent:@"Data.plist"]];
_proyectName.text = [proyectPath lastPathComponent];
int leves = [[plist objectForKey:@"numeroNiveles"] integerValue];
_levels.text = [NSString stringWithFormat:@"%d", leves];
bool revisarCimiento = [[plist objectForKey:@"revisarCimiento"] boolValue];
_revisarCimiento.text = [NSString stringWithFormat:@"%s", revisarCimiento ? "Si" : "No"];
_tipoCodigoEsfuerzosAdmisibles.text = [plist objectForKey:@"tipoCodigoEsfuerzosAdmisibles"];
_tipoUnidadMamposteria.text = [plist objectForKey:@"tipoUnidadMamposteria"];
bool mamposteriaConfinada = [[plist objectForKey:@"mamposteriaConfinada"]boolValue];
_mamposteriaConfinada.text = [NSString stringWithFormat:@"%s", mamposteriaConfinada ? "Si" : "No"];
}
@end
I don't why in the iPad Air the strings are loaded fine but in the iPad 2 not. Thanks for your attention.