.h #import <UIKit/UIKit.h> #import "AreaView.h" typedef void (^areaNumber) (NSString *); @interface AreaViewController : UIViewController{ AreaView *mainView; } @property(nonatomic,copy)areaNumber block; @end .m #import "AreaViewController.h" @interface AreaViewController () @end @implementation AreaViewController - (void)viewDidLoad { [super viewDidLoad]; self.title = @"选择地区"; mainView = [[AreaView alloc] initWithFrame:self.view.frame]; __unsafe_unretained AreaViewController *thisSelf = (AreaViewController *)self; [mainView setBlock:^(NSString *result){ thisSelf.block(result); [thisSelf.navigationController popViewControllerAnimated:YES];
}]; [self.view addSubview:mainView];
NSString *path = [[NSBundle mainBundle] pathForResource:@"areaNumber.plist" ofType:nil]; NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; // NSArray *keys = [dic allKeys]; // NSArray *resultKeys = [keys sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { // return [obj1 compare:obj2 options:NSLiteralSearch]; // }]; mainView.dic = dic; } plist文件 |
|
来自: 萤火与皓月 > 《第三方框架及类库》