UIInputViewController не будет загружать массив из plist

Я пытаюсь, чтобы одна из кнопок на моей пользовательской клавиатуре загружалась из списка, который приложение извлекает из URL. Я не могу заставить массив plist загружаться при загрузке клавиатуры, чтобы он мог читать текст при загрузке с клавиатуры.

//
//  KeyboardViewController.h
//  MyKeyboard

#import <UIKit/UIKit.h>

@interface KeyboardViewController : UIInputViewController{

NSMutableArray *keyboardArray;

}

@end

//
//  KeyboardViewController.m
//  MyKeyboard



#import "KeyboardViewController.h"
#import "Keyboard.h"
@interface KeyboardViewController ()

@property (strong,nonatomic)Keyboard *keyboard;

@end

@implementation KeyboardViewController

- (void)updateViewConstraints {
[super updateViewConstraints];

// Add custom view sizing constraints here
}

-(void)viewWillAppear:(BOOL)animated{


}


- (void)viewDidLoad {
[super viewDidLoad];

//Load Keyboard Type
NSString *keyboardName;
keyboardName = @"Keyboard";


self.keyboard = [[[NSBundle mainBundle] loadNibNamed:keyboardName owner:nil     options:nil] objectAtIndex:0];
[self addGesturesToKeyboard];

self.inputView = self.keyboard;

// Perform custom UI setup here


[self setButtons];

}

-(void)setButtons{

//Sets Text of KEY Label

//create array from Plist document of all mountains
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory =  [paths objectAtIndex:0];
NSString *plistPath = [documentsDirectory stringByAppendingPathComponent:@"databaseOfHills.plist"];
keyboardArray = [[[NSMutableArray alloc] initWithContentsOfFile:plistPath]mutableCopy];

//Sets Text of KEY Label

UIButton *btn = (UIButton*)[self.view viewWithTag:1];

NSString *selectedStringFromPlist = [[keyboardArray     objectAtIndex:0]objectForKey:@"Button1"];

[btn setTitle:selectedStringFromPlist forState:UIControlStateNormal];



}

0 ответов

Другие вопросы по тегам