Plist数据未加载到其他iOS模拟器设备中

时间:2014-12-16 23:24:40

标签: ios plist simulator

更新刚刚重置了模拟器数据,现在工作正常。

我会感激任何帮助:)

我的应用将数据写入Documents的子文件夹中的Data.plist文件。 我添加了一个NSLog来查找路径,以便我可以检查它。我发现并且plist很好。 我在iPad Air中尝试过。另一页有一个“加载”按钮,用于加载plist数据并将其放在文本字段中。在iPad Air中,信息加载完全正常。

BUT!我在iPad 2中尝试过它.2个字符串没有加载。键和对象是:

proyectName                       string example
revisarCimiento                   bool   1
tipoCodigoEsfuerzosAdmisibles     string Canada
tipoUnidadMamposteria             string Block
mamposteriaConfinada              bool   0

加载数据时,proyect名称不依赖于plist。 bool很好,但没有加载其他2个字符串。

这是代码

·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

我不知道为什么在iPad Air中字符串加载很好但在iPad 2中没有。 谢谢你的关注。

0 个答案:

没有答案