Skip to content

Commit

Permalink
Updated to version 1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Oct 8, 2014
1 parent d5d9a21 commit 1c4f3cb
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 16 deletions.
4 changes: 2 additions & 2 deletions FXForms.podspec.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "FXForms",
"version": "1.2.2",
"version": "1.2.3",
"license": "zlib",
"summary": "FXForms is an Objective-C library for easily creating table-based forms on iOS. It is ideal for settings pages or user data entry tasks.",
"homepage": "https://github.com/nicklockwood/FXForms",
"authors": "Nick Lockwood",
"source": {
"git": "https://github.com/nicklockwood/FXForms.git",
"tag": "1.2.2"
"tag": "1.2.3"
},
"source_files": "FXForms/FXForms.{h,m}",
"requires_arc": true,
Expand Down
2 changes: 1 addition & 1 deletion FXForms/FXForms.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FXForms.h
//
// Version 1.2.2
// Version 1.2.3
//
// Created by Nick Lockwood on 13/02/2014.
// Copyright (c) 2014 Charcoal Design. All rights reserved.
Expand Down
37 changes: 26 additions & 11 deletions FXForms/FXForms.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FXForms.m
//
// Version 1.2.2
// Version 1.2.3
//
// Created by Nick Lockwood on 13/02/2014.
// Copyright (c) 2014 Charcoal Design. All rights reserved.
Expand Down Expand Up @@ -94,6 +94,20 @@
static const CGFloat FXFormFieldPaddingBottom = 12;


static Class FXFormClassFromString(NSString *className)
{
Class cls = NSClassFromString(className);
if (className && !cls)
{
//might be a Swift class; time for some hackery!
className = [@[[[NSBundle mainBundle] objectForInfoDictionaryKey:(id)kCFBundleNameKey],
className] componentsJoinedByString:@"."];
//try again
cls = NSClassFromString(className);
}
return cls;
}

static UIView *FXFormsFirstResponder(UIView *view)
{
if ([view isFirstResponder])
Expand Down Expand Up @@ -215,7 +229,7 @@ static inline void FXFormLabelSetMinFontSize(UILabel *label, CGFloat fontSize)
{
name = [name substringToIndex:range.location];
}
valueClass = NSClassFromString(name) ?: [NSObject class];
valueClass = FXFormClassFromString(name) ?: [NSObject class];
free(className);
}
break;
Expand Down Expand Up @@ -382,7 +396,7 @@ static void FXFormPreprocessFieldDictionary(NSMutableDictionary *dictionary)
//convert value class from string
if ([dictionary[FXFormFieldClass] isKindOfClass:[NSString class]])
{
dictionary[FXFormFieldClass] = NSClassFromString(dictionary[FXFormFieldClass]);
dictionary[FXFormFieldClass] = FXFormClassFromString(dictionary[FXFormFieldClass]);
}

//determine value class
Expand Down Expand Up @@ -467,13 +481,13 @@ static void FXFormPreprocessFieldDictionary(NSMutableDictionary *dictionary)
//convert cell from string to class
if ([dictionary[FXFormFieldCell] isKindOfClass:[NSString class]])
{
dictionary[FXFormFieldCell] = NSClassFromString(dictionary[FXFormFieldCell]);
dictionary[FXFormFieldCell] = FXFormClassFromString(dictionary[FXFormFieldCell]);
}

//convert view controller from string to class
if ([dictionary[FXFormFieldViewController] isKindOfClass:[NSString class]])
{
dictionary[FXFormFieldViewController] = NSClassFromString(dictionary[FXFormFieldViewController]);
dictionary[FXFormFieldViewController] = FXFormClassFromString(dictionary[FXFormFieldViewController]);
}

//preprocess template dictionary
Expand Down Expand Up @@ -931,7 +945,7 @@ - (void)setValueTransformer:(id)valueTransformer
{
if ([valueTransformer isKindOfClass:[NSString class]])
{
valueTransformer = NSClassFromString(valueTransformer);
valueTransformer = FXFormClassFromString(valueTransformer);
}
if ([valueTransformer class] == valueTransformer)
{
Expand Down Expand Up @@ -975,7 +989,7 @@ - (void)setSegue:(id)segue
{
if ([segue isKindOfClass:[NSString class]])
{
segue = NSClassFromString(segue) ?: [segue copy];
segue = FXFormClassFromString(segue) ?: [segue copy];
}

NSAssert(segue != [UIStoryboardPopoverSegue class], @"Unfortunately displaying subcontrollers using UIStoryboardPopoverSegue is not supported, as doing so would require calling private methods. To display using a popover, create a custom UIStoryboard subclass instead.");
Expand Down Expand Up @@ -1022,7 +1036,7 @@ - (void)setHeader:(id)header
{
if ([header isKindOfClass:[NSString class]])
{
Class viewClass = NSClassFromString(header);
Class viewClass = FXFormClassFromString(header);
if ([viewClass isSubclassOfClass:[UIView class]])
{
header = viewClass;
Expand All @@ -1047,7 +1061,7 @@ - (void)setFooter:(id)footer
{
if ([footer isKindOfClass:[NSString class]])
{
Class viewClass = NSClassFromString(footer);
Class viewClass = FXFormClassFromString(footer);
if ([viewClass isSubclassOfClass:[UIView class]])
{
footer = viewClass;
Expand Down Expand Up @@ -1597,7 +1611,7 @@ + (NSArray *)sectionsWithForm:(id<FXForm>)form controller:(FXFormController *)fo
else if ([field.valueClass conformsToProtocol:@protocol(FXForm)] && field.isInline)
{
if (!field.value && [field respondsToSelector:@selector(init)] &&
![field.valueClass isSubclassOfClass:NSClassFromString(@"NSManagedObject")])
![field.valueClass isSubclassOfClass:FXFormClassFromString(@"NSManagedObject")])
{
//create a new instance of the form automatically
field.value = [[field.valueClass alloc] init];
Expand Down Expand Up @@ -2348,7 +2362,7 @@ - (void)setField:(FXFormField *)field
}
else if ([field.valueClass conformsToProtocol:@protocol(FXForm)])
{
if (!field.value && ![field.valueClass isSubclassOfClass:NSClassFromString(@"NSManagedObject")])
if (!field.value && ![field.valueClass isSubclassOfClass:FXFormClassFromString(@"NSManagedObject")])
{
//create a new instance of the form automatically
field.value = [[field.valueClass alloc] init];
Expand Down Expand Up @@ -2663,6 +2677,7 @@ - (void)didSelectWithTableView:(UITableView *)tableView controller:(UIViewContro
}
else
{
NSAssert(controller.navigationController != nil, @"Attempted to push a sub-viewController from a form that is not embedded inside a UINavigationController. That won't work!");
[controller.navigationController pushViewController:subcontroller animated:YES];
}
}
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FXForms

version 1.2.2, October 7th, 2014
version 1.2.3, October 8th, 2014

Copyright (C) 2014 Charcoal Design

Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FXForms is an Objective-C library for easily creating table-based forms on iOS.

Unlike other solutions, FXForms works directly with strongly-typed data models that you supply (instead of dictionaries or complicated dataSource protocols), and infers as much information as possible from your models using introspection, to avoid the need for tedious duplication of type information.

![Screenshot of BasicExample](https://raw.github.com/nicklockwood/FXForms/1.0.2/Examples/BasicExample/Screenshot.png)
![Screenshot of BasicExample](https://raw.github.com/nicklockwood/FXForms/1.2.3/Examples/BasicExample/Screenshot.png)

Supported iOS & SDK Versions
-----------------------------
Expand Down Expand Up @@ -529,10 +529,31 @@ Once you have created your custom cell, you can use it as follows:
* If your cell is designed to handle a particular field value class (or subclass), you can tell the formController to use your custom cell class for a particular value class using the `-registerCellClass:forFieldClass:` method of FXFormController.
* If you want to completely replace all cells with your own classes, use the `-registerDefaultFieldCellClass:` method of `FXFormController`. This replaces all default cell associations for all field types with your new cell class. You can then use `-registerCellClass:forFieldType:` to add additional cell classes for specific types.


Swift Compatibility
--------------------

FXForms is fully compatible with Swift, with the following caveats:

* Your forms objects must inherit from `NSObject`, or de declared using the `@objc` qualifier.
* For collection fields, you must use `NSArray`, `NSDictionary`, `NSOrderedSet`, etc. Swift's strongly typed collections won't work.
* If your form objects are declared in a different module to your main app, FXForm's field value class inference may not work correctly, in which case you can explicitly specify the field class by adding the following method to your form object for each field that doesn't work:

```swift
func fieldThatDoesntWorkField() -> NSDictionary {
return [FXFormFieldClass: fieldThatDoesntWork.dynamicType]
}
```


Release notes
--------------

Version 1.2.3

- Added a fix when using Swift to allow FXForms to automatically infer the types of forms and controllers, as it can with Objective-C
- Now throws an exception if you try to present a subform when not embedded inside a UINavigationController

Version 1.2.2

- Fixed bug where subforms would be overwritten by a new instance
Expand Down

0 comments on commit 1c4f3cb

Please sign in to comment.