BaseKit 0.2.5

BaseKit 0.2.5

测试已测试
语言语言 Obj-CObjective C
许可 Apache 2
发布最后发布2014年12月

刘万象维护。



BaseKit 0.2.5

  • 布鲁诺·威尔蒙特

BaseKit 是一组iOS类,可以使您的生活更轻松。

安装

您有两种方法可以做到这一点

  • 复制文件。
  • 使用 CocoaPods 安装。

复制文件

将代码目录添加到 Code/* 中或选择您需要的库。

教程

使用 BaseKit 创建 iPhone 和 iPad iOS 表单

类似于 Restkit 的UITableView Dynamic cell映射

核心

在后台执行操作。

[BKOperationHelper performBlockInBackground:^{
    // Do your operation in background
} completion:^{
    // Update UI in main queue
}];

迭代。

[BKIteratingHelper iterateTil:4 usingBlock:^(int number) {
    NSLog(@"%d", number);
}];

视图

使用方块显示模态视图控制器。

[self presentModalViewControllerWithBlock:^UIViewController *{
    return [[[AnyViewController alloc] init] autorelease];
} animated:YES];

使用方块推送视图控制器。

[self.navigationController pushViewControllerWithBlock:^UIViewController *{
    return [[[AnyViewController alloc] init] autorelease];
} animated:YES];

Cell 映射

self.tableModel = [BKTableModel tableModelForTableView:self.tableView];
self.tableView.dataSource = self.tableModel;
self.tableView.delegate = self.tableModel;

[BKCellMapping mappingForObjectClass:[Item class] block:^(BKCellMapping *cellMapping) {
    [cellMapping mapKeyPath:@"title" toAttribute:@"textLabel.text"];

    [cellMapping onSelectRowWithBlock:^(UITableViewCell *cell, Item *item, NSIndexPath *indexPath) {
           // Do something
    }];

    [cellMapping mapObjectToCellClass:[UITableViewCell class]];
    [self.tableModel registerMapping:cellMapping];
}];

NSArray *items = [NSArray arrayWithObjects:
                    [Item itemWithTitle:@"Simple mapping"],
                    [Item itemWithTitle:@"Nib cell example"],
                    nil];

[self.tableModel loadTableItems:items];

查看更多 示例请打开 Examples/CellMappingExample/CellMappingExample.xcodeproj项目

表单映射

非常容易地使用模型创建连接的表单。每次您添加 "mapAttribute" 时,您必须给出一个属于您的对象的属性名,在值改变后,它将自动保存到属性中。

BaseKit 使用名为 ActionSheetPicker 的外部库,但不幸的是,该库还不支持 ARC,因此您需要在将库导入项目时添加 "-fno-objc-arc"。

self.formModel = [BKFormModel formTableModelForTableView:self.tableView navigationController:self.navigationController];

[BKFormMapping mappingForClass:[Movie class] block:^(BKFormMapping *formMapping) {
    [formMapping sectiontTitle:@"Information section" identifier:@"info"];
    [formMapping mapAttribute:@"title" title:@"Title" type:BKFormAttributeMappingTypeText];
    [formMapping mapAttribute:@"releaseDate" title:@"ReleaseDate" type:BKFormAttributeMappingTypeDatePicker];
    [formMapping mapAttribute:@"suitAllAges" title:@"All ages" type:BKFormAttributeMappingTypeBoolean];
    [formMapping mapAttribute:@"shortName" title:@"ShortName" type:BKFormAttributeMappingTypeLabel];
    [formMapping mapAttribute:@"numberOfActor" title:@"Number of actor" type:BKFormAttributeMappingTypeInteger];
    [formMapping mapAttribute:@"content" title:@"Content" type:BKFormAttributeMappingTypeBigText];

    [formMapping mapAttribute:@"choice" title:@"Choices" selectValuesBlock:^NSArray *(id value, id object, NSInteger *selectedValueIndex){
        *selectedValueIndex = 1;
        return [NSArray arrayWithObjects:@"choice1", @"choice2", nil];
    } valueWithBlock:^id(id value, id object, NSInteger selectedValueIndex) {
        return value;
    }];

    [formMapping buttonSave:@"Save" handler:^{
    }];

    [self.formModel registerMapping:formMapping];
}];

[self.formModel loadFieldsWithObject:movie];

Form Mapping

查看更多 示例请打开 Examples/FormMappingExample/FormMappingExample.xcodeproj项目

LocationManager

易于使用的 CoreLocation 管理器,支持方块或默认代理。

BKLocationManager *manager = [BKLocationManager sharedManager];

[manager setDidUpdateLocationBlock:^(CLLocationManager *manager, CLLocation *newLocation, CLLocation *oldLocation) {
    NSLog(@"didUpdateLocation");
}];

[manager setDidFailBlock:^(CLLocationManager *manager, NSError *error) {
    NSLog(@"didFailUpdateLocation");
}];

[manager startUpdatingLocationWithAccuracy:kCLLocationAccuracyHundredMeters];

ARC 支持

BaseKit 完全与 ARC 和非 ARC 项目兼容。

变更日志

  • 2012/05/17 (0.2.3)

    • 修复了单元格映射的编辑样式
  • 2012/05/12 (0.2)

    • 添加了 LocationManager
    • 添加了 FormField
    • 添加了 FormMapping
  • 2012/01/29 (0.1)

    • 首次发布。

使用 BaseKit 的应用程序

如果您使用 BaseKit,我很乐意在这里添加您的应用程序名称。

LiègeExpo2017

联系

布鲁诺·威尔蒙特