我的表格如下
#import <Foundation/Foundation.h>
#import "FXForms.h"
@interface SettingsForm : NSObject <FXForm>
@property (nonatomic, copy) NSString *apsalarKey;
@property (nonatomic, copy) NSString *apsalarSecret;
@property (nonatomic, assign) BOOL apsalarIsActive;
@property (nonatomic, copy) NSString *kahunaKey;
@property (nonatomic, copy) NSString *kahunaUsername;
@property (nonatomic, copy) NSString *kahunaEmail;
@property (nonatomic, assign) BOOL kahunaIsActive;
@property (nonatomic, copy) NSString *googleAnalyticsTrackingId;
@property (nonatomic, assign) BOOL googleAnalyticsIsActive;
@end
具有以下实现
#import "SettingsForm.h"
@implementation SettingsForm
- (NSArray *)fields {
return @[
@{FXFormFieldKey : @"apsalarKey", FXFormFieldTitle : @"key", FXFormFieldHeader : @"Apsalar"},
@{FXFormFieldKey : @"apsalarSecret", FXFormFieldTitle : @"secret"},
@{FXFormFieldKey : @"apsalarIsActive", FXFormFieldTitle : @"active", FXFormFieldType: FXFormFieldTypeBoolean},
@{FXFormFieldKey : @"kahunaKey", FXFormFieldTitle : @"secret", FXFormFieldHeader : @"Kahuna"},
@{FXFormFieldKey : @"kahunaUsername", FXFormFieldTitle : @"username"},
@{FXFormFieldKey : @"kahunaEmail", FXFormFieldTitle : @"email"},
@{FXFormFieldKey : @"kahunaIsActive", FXFormFieldTitle : @"active", FXFormFieldType: FXFormFieldTypeBoolean},
@{FXFormFieldKey : @"googleAnalyticsTrackingId", FXFormFieldTitle : @"id", FXFormFieldHeader : @"Google Analytics"},
@{FXFormFieldKey : @"googleAnalyticsIsActive", FXFormFieldTitle : @"active", FXFormFieldType: FXFormFieldTypeBoolean},
@{FXFormFieldTitle : @"Clear", FXFormFieldHeader : @"Clear Log", FXFormFieldAction : @"clearLogHandler:"},
];
}
@end
我在控制器中引用表单,当我尝试获取布尔字段的值时,它会抛出异常:EXC_BAD_ACCESS:
- (IBAction)dismiss:(id)sender
{
// resign first responder, fxform fields do not set their data bound values until you click out of them,
// this will set them on clicking the 'Done' button
[self.view endEditing:YES];
// save settings
NSLog(@"active %@", self.form.apsalarKey);
NSLog(@"active %@", self.form.apsalarSecret);
NSLog(@"active %@", self.form.apsalarIsActive);
[SettingsStore setApsalarKey:self.form.apsalarKey
Secret:self.form.apsalarSecret
Active:self.form.apsalarIsActive];
第三个日志行抛出异常。
谢谢!
答案 0 :(得分:0)
Not sure if you found your answer but if anyone else is looking you can look here for how to print BOOL to the log.