Skip to content
This repository
Browse code

modernized Obj-C code

  • Loading branch information...
commit 02484b1b6d5c3ff72e922144b8a5edd9a435297c 1 parent 8fb3bb8
Robert Wijas authored

Showing 22 changed files with 574 additions and 753 deletions. Show diff stats Hide diff stats

  1. +70 92 Project/UISS/UISS.m
  2. +39 36 Project/UISS/UISSStatusView.m
  3. +6 12 Project/UISSDemo/Classes/UISSDemoAppDelegate.m
  4. +62 59 Project/UISSDemo/UISS/uiss.json
  5. +26 33 Project/UISSDemoTests/ExampleJSONTests.m
  6. +12 16 Project/UISSDemoTests/UISSCodeGeneratorTests.m
  7. +26 37 Project/UISSDemoTests/UISSColorValueConverterTests.m
  8. +7 12 Project/UISSDemoTests/UISSEdgeInsetsValueConverterTests.m
  9. +10 15 Project/UISSDemoTests/UISSFloatValueConverterTests.m
  10. +19 28 Project/UISSDemoTests/UISSFontValueConverterTests.m
  11. +17 29 Project/UISSDemoTests/UISSImageValueConverterTests.m
  12. +14 18 Project/UISSDemoTests/UISSIntegerValueConverterTests.m
  13. +10 15 Project/UISSDemoTests/UISSOffsetValueConverterTests.m
  14. +74 101 Project/UISSDemoTests/UISSParserTests.m
  15. +8 13 Project/UISSDemoTests/UISSPointValueConverterTests.m
  16. +5 8 Project/UISSDemoTests/UISSPrivateAppearanceMethodsTests.m
  17. +33 41 Project/UISSDemoTests/UISSPropertySetterTests.m
  18. +7 11 Project/UISSDemoTests/UISSRectValueConverterTests.m
  19. +9 14 Project/UISSDemoTests/UISSSizeValueConverterTests.m
  20. +32 39 Project/UISSDemoTests/UISSTextAttributesValueConverterTests.m
  21. +35 48 Project/UISSDemoTests/UISSUserInterfaceIdiomPreprocessorTests.m
  22. +53 76 Project/UISSDemoTests/UISSVariablesPreprocessorTests.m
162 Project/UISS/UISS.m
@@ -8,8 +8,6 @@
8 8
9 9 #import "UISS.h"
10 10
11   -#import <objc/runtime.h>
12   -
13 11 #import "UISSStatusViewController.h"
14 12 #import "UISSPropertySetter.h"
15 13 #import "UISSAppearancePrivate.h"
@@ -26,109 +24,103 @@
26 24
27 25 @interface UISS () <UISSStatusWindowControllerDelegate>
28 26
29   -@property (nonatomic, strong) UISSStatusViewController *statusWindowController;
30   -@property (nonatomic, strong) UISSStatusWindow *statusWindow;
  27 +@property(nonatomic, strong) UISSStatusViewController *statusWindowController;
  28 +@property(nonatomic, strong) UISSStatusWindow *statusWindow;
31 29
32   -@property (nonatomic, strong) NSTimer *autoReloadTimer;
33   -@property (nonatomic, assign) dispatch_queue_t queue; // all style parsing is done on the queue
  30 +@property(nonatomic, strong) NSTimer *autoReloadTimer;
  31 +@property(nonatomic, assign) dispatch_queue_t queue; // all style parsing is done on the queue
34 32
35   -@property (nonatomic, strong) UISSCodeGenerator *codeGenerator;
  33 +@property(nonatomic, strong) UISSCodeGenerator *codeGenerator;
36 34
37   -@property (nonatomic, strong) NSMutableArray *configuredAppearanceProxies;
  35 +@property(nonatomic, strong) NSMutableArray *configuredAppearanceProxies;
38 36
39 37 @end
40 38
41 39 @implementation UISS
42 40
43   -@synthesize config=_config;
44   -@synthesize style=_style;
  41 +@synthesize config = _config;
  42 +@synthesize style = _style;
45 43
46   -@synthesize statusWindowController=_statusWindowController;
47   -@synthesize statusWindow=_statusWindow;
  44 +@synthesize statusWindowController = _statusWindowController;
  45 +@synthesize statusWindow = _statusWindow;
48 46
49   -@synthesize autoReloadTimer=_autoReloadTimer;
50   -@synthesize queue=_queue;
  47 +@synthesize autoReloadTimer = _autoReloadTimer;
  48 +@synthesize queue = _queue;
51 49
52   -@synthesize codeGenerator=_codeGenerator;
  50 +@synthesize codeGenerator = _codeGenerator;
53 51
54   -@synthesize configuredAppearanceProxies=_configuredAppearanceProxies;
  52 +@synthesize configuredAppearanceProxies = _configuredAppearanceProxies;
55 53
56 54 #pragma mark - Contructors
57 55
58   -- (id)init
59   -{
  56 +- (id)init {
60 57 self = [super init];
61 58 if (self) {
62 59 self.config = [UISSConfig sharedConfig];
63 60 self.style = [[UISSStyle alloc] init];
64   -
  61 +
65 62 self.queue = dispatch_queue_create("com.robertwijas.uiss.queue", DISPATCH_QUEUE_SERIAL);
66   -
  63 +
67 64 self.codeGenerator = [[UISSCodeGenerator alloc] init];
68   -
  65 +
69 66 #ifdef UISS_DEBUG
70 67 self.configuredAppearanceProxies = [NSMutableArray array];
71 68 #endif
72 69 }
73   -
  70 +
74 71 return self;
75 72 }
76 73
77   -+ (UISS *)configureWithJSONFilePath:(NSString *)filePath;
78   -{
  74 ++ (UISS *)configureWithJSONFilePath:(NSString *)filePath; {
79 75 UISS *uiss = [[UISS alloc] init];
80 76 uiss.style.url = [NSURL fileURLWithPath:filePath];
81 77 [uiss load];
82 78 return uiss;
83 79 }
84 80
85   -+ (UISS *)configureWithDefaultJSONFile;
86   -{
  81 ++ (UISS *)configureWithDefaultJSONFile; {
87 82 NSString *filePath = [[NSBundle mainBundle] pathForResource:@"uiss" ofType:@"json"];
88 83 return [self configureWithJSONFilePath:filePath];
89 84 }
90 85
91   -- (void)configureAppearanceWithPropertySetters:(NSArray *)propertySetters errors:(NSMutableArray *)errors;
92   -{
  86 +- (void)configureAppearanceWithPropertySetters:(NSArray *)propertySetters errors:(NSMutableArray *)errors; {
93 87 [[NSNotificationCenter defaultCenter] postNotificationName:UISSWillApplyStyleNotification object:self];
94 88
95 89 [self resetAppearanceForPropertySetters:propertySetters];
96   -
  90 +
97 91 NSMutableArray *invocations = [NSMutableArray array];
98   -
  92 +
99 93 for (UISSPropertySetter *propertySetter in propertySetters) {
100 94 NSInvocation *invocation = propertySetter.invocation;
101 95 if (invocation) {
102 96 [invocations addObject:invocation];
103 97 } else {
104   - [errors addObject:[UISSError errorWithCode:UISSPropertySetterCreateInvocationError
105   - userInfo:[NSDictionary dictionaryWithObject:propertySetter forKey:UISSPopertySetterErrorKey]]];
  98 + [errors addObject:[UISSError errorWithCode:UISSPropertySetterCreateInvocationError
  99 + userInfo:[NSDictionary dictionaryWithObject:propertySetter
  100 + forKey:UISSPopertySetterErrorKey]]];
106 101 }
107 102 }
108   -
  103 +
109 104 for (NSInvocation *invocation in invocations) {
110 105 if ([self.configuredAppearanceProxies containsObject:invocation.target] == NO) {
111 106 [self.configuredAppearanceProxies addObject:invocation.target];
112 107 }
113   -
  108 +
114 109 [invocation invoke];
115 110 }
116 111
117 112 [[NSNotificationCenter defaultCenter] postNotificationName:UISSDidApplyStyleNotification object:self];
118 113 }
119 114
120   -- (void)reload;
121   -{
122   - NSLog(@"UISS -- reloading...");
123   -
  115 +- (void)reload; {
124 116 dispatch_async(self.queue, ^{
125 117 // if new data downloaded
126 118 if ([self.style downloadData]) {
127 119 UIUserInterfaceIdiom userInterfaceIdiom = [UIDevice currentDevice].userInterfaceIdiom;
128   -
  120 +
129 121 [self.style parseDictionaryForUserInterfaceIdiom:userInterfaceIdiom withConfig:self.config];
130 122 NSArray *propertySetters = [self.style propertySettersForUserInterfaceIdiom:userInterfaceIdiom];
131   -
  123 +
132 124 if (propertySetters) {
133 125 dispatch_async(dispatch_get_main_queue(), ^{
134 126 [self configureAppearanceWithPropertySetters:propertySetters errors:self.style.errors];
@@ -139,26 +131,24 @@ - (void)reload;
139 131 });
140 132 }
141 133
142   -- (void)load;
143   -{
  134 +- (void)load; {
144 135 __block NSArray *propertySetters = nil;
145   -
  136 +
146 137 dispatch_sync(self.queue, ^{
147 138 UIUserInterfaceIdiom userInterfaceIdiom = [UIDevice currentDevice].userInterfaceIdiom;
148 139 if ([self.style parseDictionaryForUserInterfaceIdiom:userInterfaceIdiom withConfig:self.config]) {
149 140 propertySetters = [self.style propertySettersForUserInterfaceIdiom:userInterfaceIdiom];
150 141 }
151 142 });
152   -
  143 +
153 144 if (propertySetters) {
154 145 [self configureAppearanceWithPropertySetters:propertySetters errors:self.style.errors];
155 146 }
156 147 }
157 148
158   -- (void)refreshViews;
159   -{
  149 +- (void)refreshViews; {
160 150 [[NSNotificationCenter defaultCenter] postNotificationName:UISSWillRefreshViewsNotification object:self];
161   -
  151 +
162 152 for (UIWindow *window in [UIApplication sharedApplication].windows) {
163 153 for (UIView *view in window.subviews) {
164 154 [view removeFromSuperview];
@@ -169,33 +159,31 @@ - (void)refreshViews;
169 159 [[NSNotificationCenter defaultCenter] postNotificationName:UISSDidRefreshViewsNotification object:self];
170 160 }
171 161
172   -- (void)resetAppearanceForPropertySetters:(NSArray *)propertySetters;
173   -{
  162 +- (void)resetAppearanceForPropertySetters:(NSArray *)propertySetters; {
174 163 #ifdef UISS_DEBUG
175 164 NSLog(@"UISS -- reseting appearance");
176   -
  165 +
177 166 for (id appearanceProxy in self.configuredAppearanceProxies) {
178 167 [[appearanceProxy _appearanceInvocations] removeAllObjects];
179 168 }
180   -
  169 +
181 170 [self.configuredAppearanceProxies removeAllObjects];
182 171 #endif
183 172 }
184 173
185 174 #pragma mark - Code Generation
186 175
187   -- (void)generateCodeForUserInterfaceIdiom:(UIUserInterfaceIdiom)userInterfaceIdiom
188   - codeHandler:(void (^)(NSString *code, NSArray *errors))codeHandler;
189   -{
  176 +- (void)generateCodeForUserInterfaceIdiom:(UIUserInterfaceIdiom)userInterfaceIdiom
  177 + codeHandler:(void (^)(NSString *code, NSArray *errors))codeHandler; {
190 178 NSAssert(codeHandler, @"code handler required");
191   -
  179 +
192 180 dispatch_async(self.queue, ^{
193 181 [self.style parseDictionaryForUserInterfaceIdiom:userInterfaceIdiom withConfig:self.config];
194 182 NSArray *propertySetters = [self.style propertySettersForUserInterfaceIdiom:userInterfaceIdiom];
195 183 NSMutableArray *errors = [NSMutableArray array];
196   -
  184 +
197 185 NSString *code = [self.codeGenerator generateCodeForPropertySetters:propertySetters errors:errors];
198   -
  186 +
199 187 dispatch_async(dispatch_get_main_queue(), ^{
200 188 codeHandler(code, errors);
201 189 });
@@ -204,51 +192,44 @@ - (void)generateCodeForUserInterfaceIdiom:(UIUserInterfaceIdiom)userInterfaceIdi
204 192
205 193 #pragma mark - Auto Refresh
206 194
207   -- (void)enableAutoReloadWithTimeInterval:(NSTimeInterval)timeInterval;
208   -{
  195 +- (void)enableAutoReloadWithTimeInterval:(NSTimeInterval)timeInterval; {
209 196 [self disableAutoReload];
210   -
211   - self.autoReloadTimer = [NSTimer scheduledTimerWithTimeInterval:timeInterval
212   - target:self
213   - selector:@selector(reload)
214   - userInfo:nil
215   - repeats:YES];
  197 +
  198 + self.autoReloadTimer = [NSTimer scheduledTimerWithTimeInterval:timeInterval
  199 + target:self
  200 + selector:@selector(reload)
  201 + userInfo:nil repeats:YES];
216 202 }
217 203
218   -- (void)disableAutoReload;
219   -{
  204 +- (void)disableAutoReload; {
220 205 [self.autoReloadTimer invalidate];
221 206 self.autoReloadTimer = nil;
222 207 }
223 208
224 209 #pragma mark - Reload Gesture Recognizer Support
225 210
226   -- (UIGestureRecognizer *)defaultGestureRecognizer;
227   -{
  211 +- (UIGestureRecognizer *)defaultGestureRecognizer; {
228 212 UILongPressGestureRecognizer *recognizer = [[UILongPressGestureRecognizer alloc] init];
229 213 recognizer.numberOfTouchesRequired = 1;
230 214 recognizer.minimumPressDuration = 1;
231   -
  215 +
232 216 return recognizer;
233 217 }
234 218
235   -- (void)registerReloadGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer inView:(UIView *)view;
236   -{
  219 +- (void)registerReloadGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer inView:(UIView *)view; {
237 220 if (gestureRecognizer == nil) {
238 221 gestureRecognizer = [self defaultGestureRecognizer];
239 222 }
240   -
  223 +
241 224 [gestureRecognizer addTarget:self action:@selector(reloadGestureRecognizerHandler:)];
242 225 [view addGestureRecognizer:gestureRecognizer];
243 226 }
244 227
245   -- (void)registerReloadGestureRecognizerInView:(UIView *)view;
246   -{
  228 +- (void)registerReloadGestureRecognizerInView:(UIView *)view; {
247 229 [self registerReloadGestureRecognizer:nil inView:view];
248 230 }
249 231
250   -- (void)reloadGestureRecognizerHandler:(UILongPressGestureRecognizer *)gestureRecognizer;
251   -{
  232 +- (void)reloadGestureRecognizerHandler:(UILongPressGestureRecognizer *)gestureRecognizer; {
252 233 if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
253 234 [self reload];
254 235 }
@@ -257,28 +238,27 @@ - (void)reloadGestureRecognizerHandler:(UILongPressGestureRecognizer *)gestureRe
257 238
258 239 #pragma mark - Status Window
259 240
260   -- (BOOL)statusWindowEnabled;
261   -{
  241 +- (BOOL)statusWindowEnabled; {
262 242 return self.statusWindow != nil;
263 243 }
264 244
265   -- (void)setStatusWindowEnabled:(BOOL)statusWindowEnabled;
266   -{
  245 +- (void)setStatusWindowEnabled:(BOOL)statusWindowEnabled; {
267 246 if (statusWindowEnabled) {
268 247 if (self.statusWindowController == nil) {
269 248 // configure Console
270   - NSString *filePath = [[NSBundle mainBundle] pathForResource:@"uiss_console" ofType:@"json" inDirectory:@"UISSResources.bundle"];
  249 + NSString *filePath = [[NSBundle mainBundle] pathForResource:@"uiss_console" ofType:@"json"
  250 + inDirectory:@"UISSResources.bundle"];
271 251 if (filePath) {
272 252 [UISS configureWithJSONFilePath:filePath];
273 253 }
274   -
  254 +
275 255 self.statusWindow = [[UISSStatusWindow alloc] init];
276   -
  256 +
277 257 UISSStatusViewController *statusWindowController = [[UISSStatusViewController alloc] init];
278 258 statusWindowController.delegate = self;
279   -
  259 +
280 260 self.statusWindow.rootViewController = statusWindowController;
281   -
  261 +
282 262 self.statusWindow.hidden = NO;
283 263 }
284 264 } else {
@@ -289,18 +269,16 @@ - (void)setStatusWindowEnabled:(BOOL)statusWindowEnabled;
289 269
290 270 #pragma mark - Console
291 271
292   -- (void)statusWindowControllerDidSelect:(UISSStatusViewController *)statusWindowController;
293   -{
  272 +- (void)statusWindowControllerDidSelect:(UISSStatusViewController *)statusWindowController; {
294 273 [self presentConsoleViewController];
295 274 }
296 275
297   -- (void)presentConsoleViewController;
298   -{
  276 +- (void)presentConsoleViewController; {
299 277 UISSConsoleViewController *consoleViewController = [[UISSConsoleViewController alloc] initWithUISS:self];
300 278 consoleViewController.modalPresentationStyle = UIModalPresentationFormSheet;
301   -
  279 +
302 280 UIViewController *presentingViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
303   -
  281 +
304 282 if (presentingViewController.presentedViewController) {
305 283 if ([presentingViewController.presentedViewController isKindOfClass:[UISSConsoleViewController class]]) {
306 284 [presentingViewController dismissViewControllerAnimated:YES completion:nil];
75 Project/UISS/UISSStatusView.m
@@ -10,83 +10,86 @@
10 10
11 11 @interface UISSStatusView ()
12 12
13   -@property (nonatomic, strong, readwrite) UILabel *titleLabel;
14   -@property (nonatomic, strong, readwrite) UILabel *statusLabel;
15   -@property (nonatomic, strong, readwrite) UIActivityIndicatorView *activityIndicator;
  13 +@property(nonatomic, strong, readwrite) UILabel *titleLabel;
  14 +@property(nonatomic, strong, readwrite) UILabel *statusLabel;
  15 +@property(nonatomic, strong, readwrite) UIActivityIndicatorView *activityIndicator;
16 16
17   -@property (nonatomic, assign) BOOL error;
  17 +@property(nonatomic, assign) BOOL error;
18 18
19 19 @end
20 20
21 21 @implementation UISSStatusView
22 22
23   -@synthesize titleLabel=_titleLabel;
24   -@synthesize statusLabel=_statusLabel;
25   -@synthesize activityIndicator=_activityIndicator;
  23 +@synthesize titleLabel = _titleLabel;
  24 +@synthesize statusLabel = _statusLabel;
  25 +@synthesize activityIndicator = _activityIndicator;
26 26
27   -@synthesize error=_error;
  27 +@synthesize error = _error;
28 28
29   -- (id)initWithFrame:(CGRect)frame
30   -{
  29 +- (id)initWithFrame:(CGRect)frame {
31 30 self = [super initWithFrame:frame];
32 31 if (self) {
33 32 self.titleLabel = [[UILabel alloc] initWithFrame:
34   - CGRectInset(CGRectMake(0, 0, roundf(self.bounds.size.width*0.5), self.bounds.size.height), 5, 0)];
35   -
36   - self.titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleRightMargin;
37   - self.titleLabel.textAlignment = UITextAlignmentLeft;
38   -
  33 + CGRectInset(CGRectMake(0, 0, roundf(self.bounds.size.width * 0.5), self.bounds.size.height), 5, 0)];
  34 +
  35 + self.titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleRightMargin;
  36 + self.titleLabel.textAlignment = NSTextAlignmentLeft;
  37 +
39 38 self.statusLabel = [[UILabel alloc] initWithFrame:
40   - CGRectInset(CGRectMake(roundf(self.bounds.size.width*0.5), 0, roundf(self.bounds.size.width*0.5), self.bounds.size.height), 5, 0)];
41   -
42   - self.statusLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleLeftMargin;
43   - self.statusLabel.textAlignment = UITextAlignmentRight;
44   -
  39 + CGRectInset(CGRectMake(roundf(self.bounds.size.width * 0.5), 0, roundf(self.bounds.size.width * 0.5), self.bounds.size.height), 5, 0)];
  40 +
  41 + self.statusLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin;
  42 + self.statusLabel.textAlignment = NSTextAlignmentRight;
  43 +
45 44 self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
46   - self.activityIndicator.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin;
47   - self.activityIndicator.center = CGPointMake(roundf(self.bounds.size.width*0.5), roundf(self.bounds.size.height*0.5));
  45 + self.activityIndicator.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
  46 + self.activityIndicator.center = CGPointMake(roundf(self.bounds.size.width * 0.5), roundf(self.bounds.size.height * 0.5));
48 47 self.activityIndicator.transform = CGAffineTransformMakeScale(0.75, 0.75);
49   -
  48 +
50 49 [self addSubview:self.titleLabel];
51 50 [self addSubview:self.statusLabel];
52 51 [self addSubview:self.activityIndicator];
53 52 }
54   -
  53 +
55 54 return self;
56 55 }
57 56
58   -- (void)setTitle:(NSString *)title status:(NSString *)status activity:(BOOL)activity error:(BOOL)error;
59   -{
  57 +- (void)stopAnimatingActivityIndicator {
  58 + [self.activityIndicator startAnimating];
  59 +}
  60 +
  61 +- (void)setTitle:(NSString *)title status:(NSString *)status activity:(BOOL)activity error:(BOOL)error; {
60 62 self.titleLabel.text = title;
61 63 self.statusLabel.text = status;
62   -
  64 +
  65 + // stop animation with delay to prevent flickering
63 66 if (activity) {
  67 + [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(stopAnimatingActivityIndicator)
  68 + object:nil];
64 69 [self.activityIndicator startAnimating];
65 70 } else {
66   - [self.activityIndicator stopAnimating];
  71 + [self performSelector:@selector(stopAnimatingActivityIndicator) withObject:nil afterDelay:0.5];
67 72 }
68   -
  73 +
69 74 self.error = error;
70   -
  75 +
71 76 [self updateStyle];
72 77 }
73 78
74   -- (void)updateStyle;
75   -{
  79 +- (void)updateStyle; {
76 80 // this prevents from changing status window style by UIAppearance proxies
77 81 self.backgroundColor = self.error ? [UIColor redColor] : [UIColor colorWithWhite:0.2 alpha:1];
78   -
  82 +
79 83 self.statusLabel.font = [UIFont boldSystemFontOfSize:12];
80 84 self.statusLabel.textColor = [UIColor whiteColor];
81 85 self.statusLabel.backgroundColor = self.backgroundColor;
82   -
  86 +
83 87 self.titleLabel.font = [UIFont boldSystemFontOfSize:12];
84 88 self.titleLabel.textColor = [UIColor whiteColor];
85 89 self.titleLabel.backgroundColor = self.backgroundColor;
86 90 }
87 91
88   -- (void)layoutSubviews;
89   -{
  92 +- (void)layoutSubviews; {
90 93 [super layoutSubviews];
91 94 [self updateStyle];
92 95 }
18 Project/UISSDemo/Classes/UISSDemoAppDelegate.m
@@ -9,13 +9,9 @@
9 9 #import "UISSDemoAppDelegate.h"
10 10 #import "UISS.h"
11 11
12   -#import "UISSDemoSecondViewController.h"
13   -#import "UISSStatusWindow.h"
14   -
15 12 @interface UISSDemoAppDelegate ()
16 13
17   -@property (nonatomic, strong) UISS *uiss;
18   -@property (nonatomic, strong) UISSStatusWindow *statusWindow;
  14 +@property(nonatomic, strong) UISS *uiss;
19 15
20 16 @end
21 17
@@ -23,10 +19,8 @@ @implementation UISSDemoAppDelegate
23 19
24 20 @synthesize window = _window;
25 21 @synthesize uiss = _uiss;
26   -@synthesize statusWindow = _statusWindow;
27 22
28   -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
29   -{
  23 +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
30 24 // skip the rest if running tests
31 25 if ([[[NSProcessInfo processInfo] environment] objectForKey:@"TEST"]) {
32 26 return YES;
@@ -38,12 +32,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
38 32 [self.uiss registerReloadGestureRecognizerInView:self.window];
39 33
40 34 [self.uiss load];
41   - [self.uiss enableAutoReloadWithTimeInterval:1];
42   -
43   -
  35 + [self.uiss enableAutoReloadWithTimeInterval:0.1];
  36 +
  37 +
44 38 // Local style
45 39 //[UISS configureWithDefaultJSONFile];
46   -
  40 +
47 41 return YES;
48 42 }
49 43
121 Project/UISSDemo/UISS/uiss.json
... ... @@ -1,85 +1,88 @@
1 1 {
2   - "Variables": {
3   - "tabbarColor": "darkGray",
4   - "buttonTitleColor": [13, 107, 180, 1.0],
5   - "buttonTitieColorHighlighted": "magenta",
6   - "font": ["italic", 22]
  2 + "Variables":{
  3 + "tabbarColor":"darkGray",
  4 + "buttonTitleColor":[13, 107, 1, 1.0],
  5 + "buttonTitieColorHighlighted":"magenta",
  6 + "font":["italic", 22]
7 7 },
8   - "Phone": {
9   - "UINavigationBar": {
10   - "tintColor": "gray"
  8 + "Phone":{
  9 + "UINavigationBar":{
  10 + "tintColor":"gray"
11 11 }
12 12 },
13   - "Pad": {
14   - "UINavigationBar": {
15   - "backgroundImage:default": "background.png"
  13 + "Pad":{
  14 + "UINavigationBar":{
  15 + "backgroundImage:default":"background"
16 16 }
17 17 },
18 18
19   - "UITabBar": {
20   - "tintColor": "$tabbarColor",
21   - "selectedImageTintColor": "blue",
22   - "UITabBarItem": {
23   - "titleTextAttributes:normal": {"textColor": "lightGray"},
24   - "titleTextAttributes:selected": {"textColor": "white"}
  19 + "UITabBar":{
  20 + "tintColor":"$tabbarColor",
  21 + "selectedImageTintColor":"blue",
  22 + "UITabBarItem":{
  23 + "titleTextAttributes:normal":{
  24 + "textColor":"lightGray"
  25 + },
  26 + "titleTextAttributes:selected":{
  27 + "textColor":"white"
  28 + }
25 29 },
26   - "UILabel": {
27   - "backgroundColor": "clear"
  30 + "UILabel":{
  31 + "backgroundColor":"clear"
28 32 }
29 33 },
30   - "UIToolbar": {
31   - "tintColor": "darkGray",
32   - "backgroundImage:bottom:default": "background"
  34 + "UIToolbar":{
  35 + "tintColor":"#112233",
  36 + "backgroundImage:bottom:default":"background"
33 37 },
34   - "UISSCustomView": {
35   - "debugBorderColor": "red",
36   - "image": "background.png",
37   - "backgroundColor": "gray",
38   - "backgroundMargin": 20,
39   - "UIImageView": {
40   - "backgroundColor": ["lightGray", 0.2]
  38 + "UISSCustomView":{
  39 + "image":"background.png",
  40 + "backgroundColor":"gray",
  41 + "backgroundMargin":40,
  42 + "UIImageView":{
  43 + "backgroundColor":["red", 0.25]
41 44 }
42 45 },
43   - "UILabel": {
44   - "Phone": {
45   - "textColor": "blue"
  46 + "UILabel":{
  47 + "Phone":{
  48 + "textColor":"blue"
46 49 },
47   - "Pad": {
48   - "textColor": "orange",
49   - "backgroundColor": "green"
  50 + "Pad":{
  51 + "textColor":"orange",
  52 + "backgroundColor":"green"
50 53 }
51 54 },
52   - "UISSCustomContainerView": {
53   - "backgroundColor": ["#8899ff", 0.5]
  55 + "UISSCustomContainerView":{
  56 + "backgroundColor":["red", 0.5]
54 57 },
55   - "@Controllers": {
56   - "UISSDemoSecondViewController": {
57   - "UILabel": {
58   - "textColor": "white",
59   - "backgroundColor": "black"
  58 + "@Controllers":{
  59 + "UISSDemoSecondViewController":{
  60 + "UILabel":{
  61 + "textColor":"white",
  62 + "backgroundColor":"black"
60 63 },
61   - "UISSCustomContainerView": {
62   - "debugBorderColor": "black",
63   - "UILabel": {
64   - "backgroundColor": "white",
65   - "textColor": "black"
  64 + "UISSCustomContainerView":{
  65 + "debugBorderColor":"black",
  66 + "UILabel":{
  67 + "backgroundColor":"blue",
  68 + "textColor":"white"
66 69 }
67 70 }
68 71 },
69   - "UISSDemoFirstViewController": {
70   - "UIButton": {
71   - "titleColor:normal": "$buttonTitleColor",
72   - "titleColor:highlighted": "$buttonTitieColorHighlighted",
73   - "backgroundImage:highlighted": "background",
74   - "UILabel": {
75   - "backgroundColor": "clear",
76   - "font": 14
  72 + "UISSDemoFirstViewController":{
  73 + "UIButton":{
  74 + "titleColor:normal":"$buttonTitleColor",
  75 + "titleColor:highlighted":"red",
  76 + "backgroundImage:highlighted":null,
  77 + "UILabel":{
  78 + "backgroundColor":"clear",
  79 + "font":16
77 80 }
78 81 },
79   - "UILabel": {
80   - "textColor": ["white", 0.75],
81   - "backgroundColor": "#334455",
82   - "font": ["Cochin-Italic", 28]
  82 + "UILabel":{
  83 + "textColor":["white", 0.6],
  84 + "backgroundColor":"#334466",
  85 + "font":["Cochin-Italic", 30]
83 86 }
84 87 }
85 88 }
59 Project/UISSDemoTests/ExampleJSONTests.m
@@ -11,72 +11,65 @@
11 11
12 12 @interface ExampleJSONTests : SenTestCase
13 13
14   -@property (nonatomic, strong) UISS *uiss;
  14 +@property(nonatomic, strong) UISS *uiss;
15 15
16 16 @end
17 17
18 18 @implementation ExampleJSONTests
19 19
20   -@synthesize uiss=_uiss;
  20 +@synthesize uiss = _uiss;
21 21
22   -- (void)setUp
23   -{
  22 +- (void)setUp {
24 23 [super setUp];
25   -
  24 +
26 25 NSString *jsonFilePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"example" ofType:@"json"];
27 26 self.uiss = [UISS configureWithJSONFilePath:jsonFilePath];
28 27 }
29 28
30   -- (void)testGeneratedCodeForPad;
31   -{
32   - [self.uiss generateCodeForUserInterfaceIdiom:UIUserInterfaceIdiomPad codeHandler:^(NSString *code, NSArray *errors) {
33   - STAssertTrue(errors.count == 0, @"errors are unexpected");
34   - STAssertNotNil(code, nil);
35   - STAssertTrue([code rangeOfString:@"[[UINavigationBar appearance] setTintColor:[UIColor greenColor]];"].location != NSNotFound, nil);
36   - }];
  29 +- (void)testGeneratedCodeForPad; {
  30 + [self.uiss generateCodeForUserInterfaceIdiom:UIUserInterfaceIdiomPad
  31 + codeHandler:^(NSString *code, NSArray *errors) {
  32 + STAssertTrue(errors.count == 0, @"errors are unexpected");
  33 + STAssertNotNil(code, nil);
  34 + STAssertTrue([code rangeOfString:@"[[UINavigationBar appearance] setTintColor:[UIColor greenColor]];"].location != NSNotFound, nil);
  35 + }];
37 36 }
38 37
39   -- (void)testGeneratedCodeForPhone;
40   -{
41   - [self.uiss generateCodeForUserInterfaceIdiom:UIUserInterfaceIdiomPhone codeHandler:^(NSString *code, NSArray *errors) {
42   - STAssertTrue(errors.count == 0, @"errors are unexpected");
43   - STAssertNotNil(code, nil);
44   - STAssertTrue([code rangeOfString:@"[[UINavigationBar appearance] setTintColor:[UIColor redColor]];"].location != NSNotFound, nil);
45   - }];
  38 +- (void)testGeneratedCodeForPhone; {
  39 + [self.uiss generateCodeForUserInterfaceIdiom:UIUserInterfaceIdiomPhone
  40 + codeHandler:^(NSString *code, NSArray *errors) {
  41 + STAssertTrue(errors.count == 0, @"errors are unexpected");
  42 + STAssertNotNil(code, nil);
  43 + STAssertTrue([code rangeOfString:@"[[UINavigationBar appearance] setTintColor:[UIColor redColor]];"].location != NSNotFound, nil);
  44 + }];
46 45 }
47 46
48   -- (void)testToolbarTintColor;
49   -{
  47 +- (void)testToolbarTintColor; {
50 48 STAssertEqualObjects([[UIToolbar appearance] tintColor], [UIColor yellowColor], nil);
51 49 }
52 50
53   -- (void)testToolbarBackgroundImage;
54   -{
55   - UIImage *backgroundImage = [[UIToolbar appearance] backgroundImageForToolbarPosition:UIToolbarPositionAny
  51 +- (void)testToolbarBackgroundImage; {
  52 + UIImage *backgroundImage = [[UIToolbar appearance] backgroundImageForToolbarPosition:UIToolbarPositionAny
56 53 barMetrics:UIBarMetricsDefault];
57 54 STAssertNotNil(backgroundImage, nil);
58 55 STAssertEqualObjects([backgroundImage class], [UIImage class], @"bad property class", nil);
59 56 }
60 57
61   -- (void)testTabBarItemTitlePositionAdjustment;
62   -{
  58 +- (void)testTabBarItemTitlePositionAdjustment; {
63 59 UIOffset titlePositionAdjustment = [[UITabBarItem appearance] titlePositionAdjustment];
64 60 STAssertEquals(titlePositionAdjustment, UIOffsetMake(10, 10), nil);
65 61 }
66 62
67   -- (void)testNavigationBarTitleVerticalPositionAdjustment;
68   -{
  63 +- (void)testNavigationBarTitleVerticalPositionAdjustment; {
69 64 STAssertEquals([[UINavigationBar appearance] titleVerticalPositionAdjustmentForBarMetrics:UIBarMetricsDefault], 10.0f, nil);
70 65 }
71 66
72   -- (void)testNavigationBarBackgroundImageForBarMetricsLandscapePhone;
73   -{
  67 +- (void)testNavigationBarBackgroundImageForBarMetricsLandscapePhone; {
74 68 STAssertNotNil([[UINavigationBar appearance] backgroundImageForBarMetrics:UIBarMetricsLandscapePhone], nil);
75 69 }
76 70
77   -- (void)testTabBarItemTitleTextAttributes;
78   -{
79   - UIFont *font = [[[UITabBarItem appearance] titleTextAttributesForState:UIControlStateNormal] objectForKey:UITextAttributeFont];
  71 +- (void)testTabBarItemTitleTextAttributes; {
  72 + UIFont *font = [[UITabBarItem appearance] titleTextAttributesForState:UIControlStateNormal][UITextAttributeFont];
80 73 STAssertNotNil(font, nil);
81 74 if (font) {
82 75 STAssertEqualObjects(font, [UIFont systemFontOfSize:24], nil);
28 Project/UISSDemoTests/UISSCodeGeneratorTests.m
@@ -9,11 +9,10 @@
9 9 #import <SenTestingKit/SenTestingKit.h>
10 10 #import "UISSCodeGenerator.h"
11 11 #import "UISSPropertySetter.h"
12   -#import "UISSProperty.h"
13 12
14 13 @interface UISSCodeGeneratorTests : SenTestCase
15 14
16   -@property (nonatomic, strong) UISSCodeGenerator *codeGenerator;
  15 +@property(nonatomic, strong) UISSCodeGenerator *codeGenerator;
17 16
18 17 @end
19 18
@@ -21,36 +20,33 @@ @implementation UISSCodeGeneratorTests
21 20
22 21 @synthesize codeGenerator;
23 22
24   -- (void)testCodeGenerationWithGroups;
25   -{
  23 +- (void)testCodeGenerationWithGroups; {
26 24 UISSPropertySetter *propertySetter = [[UISSPropertySetter alloc] init];
27 25 propertySetter.group = @"Group";
28 26 propertySetter.appearanceClass = [UIToolbar class];
29   -
  27 +
30 28 UISSProperty *property = [[UISSProperty alloc] init];
31 29 property.name = @"tintColor";
32 30 property.value = @"green";
33   -
  31 +
34 32 propertySetter.property = property;
35   -
  33 +
36 34 NSMutableArray *errors = [NSMutableArray array];
37   -
38   - NSString *code = [self.codeGenerator generateCodeForPropertySetters:[NSArray arrayWithObject:propertySetter] errors:errors];
39   -
  35 +
  36 + NSString *code = [self.codeGenerator generateCodeForPropertySetters:@[propertySetter] errors:errors];
  37 +
40 38 STAssertNotNil(code, nil);
41   - STAssertEquals(errors.count, (NSUInteger)0, nil);
42   -
  39 + STAssertEquals(errors.count, (NSUInteger) 0, nil);
  40 +
43 41 NSString *expectedCode = [NSString stringWithFormat:@"// Group\n%@\n", [propertySetter generatedCode]];
44 42 STAssertEqualObjects(code, expectedCode, nil);
45 43 }
46 44
47   -- (void)setUp;
48   -{
  45 +- (void)setUp; {
49 46 self.codeGenerator = [[UISSCodeGenerator alloc] init];
50 47 }
51 48
52   -- (void)tearDown;
53   -{
  49 +- (void)tearDown; {
54 50 self.codeGenerator = nil;
55 51 }
56 52
63 Project/UISSDemoTests/UISSColorValueConverterTests.m
@@ -19,31 +19,27 @@ @implementation UISSColorValueConverterTests
19 19
20 20 @synthesize converter = _converter;
21 21
22   -- (void)testNull;
23   -{
  22 +- (void)testNull; {
24 23 UIColor *color = [self.converter convertValue:[NSNull null]];
25 24 STAssertNil(color, nil);
26   -
  25 +
27 26 NSString *code = [self.converter generateCodeForValue:[NSNull null]];
28 27 STAssertEqualObjects(code, @"nil", nil);
29 28 }
30 29
31   -- (void)testExactColorSelector;
32   -{
  30 +- (void)testExactColorSelector; {
33 31 [self testColorValue:@"yellowColor" expectedColor:[UIColor yellowColor] expectedCode:@"[UIColor yellowColor]"];
34 32 [self testColorValue:@"redColor" expectedColor:[UIColor redColor] expectedCode:@"[UIColor redColor]"];
35 33 [self testColorValue:@"badColor" expectedColor:nil expectedCode:nil];
36 34 }
37 35
38   -- (void)testSelectorWithoutColorSuffix;
39   -{
  36 +- (void)testSelectorWithoutColorSuffix; {
40 37 [self testColorValue:@"yellow" expectedColor:[UIColor yellowColor] expectedCode:@"[UIColor yellowColor]"];
41 38 [self testColorValue:@"red" expectedColor:[UIColor redColor] expectedCode:@"[UIColor redColor]"];
42 39 [self testColorValue:@"bad" expectedColor:nil expectedCode:nil];
43 40 }
44 41
45   -- (void)testHexColor;
46   -{
  42 +- (void)testHexColor; {
47 43 [self testColorValue:@"#000000"
48 44 expectedColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:1]
49 45 expectedCode:@"[UIColor colorWithRed:0.000 green:0.000 blue:0.000 alpha:1.000]"];
@@ -53,48 +49,43 @@ - (void)testHexColor;
53 49 expectedCode:@"[UIColor colorWithRed:1.000 green:0.000 blue:0.000 alpha:1.000]"];
54 50 }
55 51
56   -- (void)testRGBArray;
57   -{
58   - [self testColorValue:[NSArray arrayWithObjects:[NSNumber numberWithInt:0], [NSNumber numberWithInt:0],
59   - [NSNumber numberWithInt:0], nil]
60   - expectedColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:1]
  52 +- (void)testRGBArray; {
  53 + [self testColorValue:@[@0, @0,
  54 + @0]
  55 + expectedColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:1]
61 56 expectedCode:@"[UIColor colorWithRed:0.000 green:0.000 blue:0.000 alpha:1.000]"];
62 57
63   - [self testColorValue:[NSArray arrayWithObjects:[NSNumber numberWithInt:255], [NSNumber numberWithInt:0],
64   - [NSNumber numberWithInt:0], nil]
65   - expectedColor:[UIColor redColor]
  58 + [self testColorValue:@[@255, @0,
  59 + @0]
  60 + expectedColor:[UIColor redColor]
66 61 expectedCode:@"[UIColor colorWithRed:1.000 green:0.000 blue:0.000 alpha:1.000]"];
67 62 }
68 63
69   -- (void)testColorsWithAlpha;
70   -{
71   - [self testColorValue:[NSArray arrayWithObjects:[NSNumber numberWithInt:255], [NSNumber numberWithInt:0],
72   - [NSNumber numberWithInt:0], [NSNumber numberWithFloat:0.2], nil]
73   - expectedColor:[UIColor colorWithRed:1 green:0 blue:0 alpha:0.2]
  64 +- (void)testColorsWithAlpha; {
  65 + [self testColorValue:@[@255, @0,
  66 + @0, @0.2f]
  67 + expectedColor:[UIColor colorWithRed:1 green:0 blue:0 alpha:0.2]
74 68 expectedCode:@"[UIColor colorWithRed:1.000 green:0.000 blue:0.000 alpha:0.200]"];
75 69
76   - [self testColorValue:[NSArray arrayWithObjects:@"yellow", [NSNumber numberWithFloat:0.2], nil]
77   - expectedColor:[[UIColor yellowColor] colorWithAlphaComponent:0.2]
  70 + [self testColorValue:@[@"yellow", @0.2f]
  71 + expectedColor:[[UIColor yellowColor] colorWithAlphaComponent:0.2]
78 72 expectedCode:@"[[UIColor yellowColor] colorWithAlphaComponent:0.200]"];
79 73
80   - [self testColorValue:[NSArray arrayWithObjects:@"#00ff00", [NSNumber numberWithFloat:0.2], nil]
81   - expectedColor:[[UIColor greenColor] colorWithAlphaComponent:0.2]
  74 + [self testColorValue:@[@"#00ff00", @0.2f]
  75 + expectedColor:[[UIColor greenColor] colorWithAlphaComponent:0.2]
82 76 expectedCode:@"[[UIColor colorWithRed:0.000 green:1.000 blue:0.000 alpha:1.000] colorWithAlphaComponent:0.200]"];
83 77 }
84 78
85   -- (void)testColorWithPatternImage;
86   -{
  79 +- (void)testColorWithPatternImage; {
87 80 [self testColorValue:@"background"
88   - expectedColor:(id)[NSNull null]
  81 + expectedColor:(id) [NSNull null]
89 82 expectedCode:@"[UIColor colorWithPatternImage:[UIImage imageNamed:@\"background\"]]"];
90 83
91 84 [self testColorValue:@"fakeImage"
92   - expectedColor:nil
93   - expectedCode:nil];
  85 + expectedColor:nil expectedCode:nil];
94 86 }
95 87
96   -- (void)testColorValue:(id)value expectedColor:(UIColor *)expectedColor expectedCode:(NSString *)expectedCode;
97   -{
  88 +- (void)testColorValue:(id)value expectedColor:(UIColor *)expectedColor expectedCode:(NSString *)expectedCode; {
98 89 UIColor *color = [self.converter convertValue:value];
99 90 NSString *code = [self.converter generateCodeForValue:value];
100 91
@@ -108,13 +99,11 @@ - (void)testColorValue:(id)value expectedColor:(UIColor *)expectedColor expected
108 99 STAssertEqualObjects(code, expectedCode, nil);
109 100 }
110 101
111   -- (void)setUp;
112   -{
  102 +- (void)setUp; {
113 103 self.converter = [[UISSColorValueConverter alloc] init];
114 104 }
115 105
116   -- (void)tearDown;
117   -{
  106 +- (void)tearDown; {
118 107 self.converter = nil;
119 108 }
120 109
19 Project/UISSDemoTests/UISSEdgeInsetsValueConverterTests.m
@@ -19,24 +19,19 @@ @implementation UISSEdgeInsetsValueConverterTests
19 19
20 20 @synthesize converter = _converter;
21 21
22   -- (void)setUp;
23   -{
  22 +- (void)setUp; {
24 23 self.converter = [[UISSEdgeInsetsValueConverter alloc] init];
25 24 }
26 25
27   -- (void)tearDown;
28   -{
  26 +- (void)tearDown; {
29 27 self.converter = nil;
30 28 }
31 29
32   -- (void)testEdgeInsetsAsArray;
33   -{
34   - id value = [NSArray arrayWithObjects:
35   - [NSNumber numberWithFloat:1],
36   - [NSNumber numberWithFloat:2],
37   - [NSNumber numberWithFloat:3],
38   - [NSNumber numberWithFloat:4],
39   - nil];
  30 +- (void)testEdgeInsetsAsArray; {
  31 + id value = @[@1.0f,
  32 + @2.0f,
  33 + @3.0f,
  34 + @4.0f];
40 35
41 36 id converted = [self.converter convertValue:value];
42 37 NSString *code = [self.converter generateCodeForValue:value];
25 Project/UISSDemoTests/UISSFloatValueConverterTests.m
@@ -11,43 +11,38 @@
11 11
12 12 @interface UISSFloatValueConverterTests : SenTestCase
13 13
14   -@property (nonatomic, strong) UISSFloatValueConverter *converter;
  14 +@property(nonatomic, strong) UISSFloatValueConverter *converter;
15 15
16 16 @end
17 17
18 18 @implementation UISSFloatValueConverterTests
19 19
20   -@synthesize converter=_converter;
  20 +@synthesize converter = _converter;
21 21
22   -- (void)setUp;
23   -{
  22 +- (void)setUp; {
24 23 self.converter = [[UISSFloatValueConverter alloc] init];
25 24 self.converter.precision = 4;
26 25 }
27 26
28   -- (void)tearDown;
29   -{
  27 +- (void)tearDown; {
30 28 self.converter = nil;
31 29 }
32 30
33   -- (void)testConversionFromNumber;
34   -{
35   - id value = [self.converter convertValue:[NSNumber numberWithFloat:0.5f]];
  31 +- (void)testConversionFromNumber; {
  32 + id value = [self.converter convertValue:@0.5f];
36 33 STAssertTrue([value isKindOfClass:[NSValue class]], nil);
37   -
  34 +
38 35 CGFloat floatValue = 0;
39 36 [value getValue:&floatValue];
40   -
  37 +
41 38 STAssertEquals(floatValue, 0.5f, nil);
42 39 }
43 40
44   -- (void)testGeneratedCodeFromString;
45   -{
  41 +- (void)testGeneratedCodeFromString; {
46 42 STAssertEqualObjects([self.converter generateCodeForValue:@"1.123"], @"1.1230", nil);
47 43 }
48 44
49   -- (void)testGeneratedCodeFromNumber;
50   -{
  45 +- (void)testGeneratedCodeFromNumber; {
51 46 STAssertEqualObjects([self.converter generateCodeForValue:[NSNumber numberWithFloat:1.123]], @"1.1230", nil);
52 47 }
53 48
47 Project/UISSDemoTests/UISSFontValueConverterTests.m
@@ -19,45 +19,38 @@ @implementation UISSFontValueConverterTests
19 19
20 20 @synthesize converter;
21 21
22   -- (void)testHelveticaNeue;
23   -{
24   - id value = [NSArray arrayWithObjects:@"HelveticaNeue",
25   - [NSNumber numberWithFloat:16],
26   - nil];
27   - [self testValue:value expectedFont:[UIFont fontWithName:@"HelveticaNeue" size:16] expectedCode:@"[UIFont fontWithName:@\"HelveticaNeue\" size:16.0]"];
  22 +- (void)testHelveticaNeue; {
  23 + id value = @[@"HelveticaNeue",
  24 + @16.0f];
  25 + [self testValue:value expectedFont:[UIFont fontWithName:@"HelveticaNeue" size:16]
  26 + expectedCode:@"[UIFont fontWithName:@\"HelveticaNeue\" size:16.0]"];
28 27 }
29 28
30   -- (void)testDefaultSystemFontAsNumber;
31   -{
32   - id value = [NSNumber numberWithFloat:14];
  29 +- (void)testDefaultSystemFontAsNumber; {
  30 + id value = @14.0f;
33 31 [self testValue:value expectedFont:[UIFont systemFontOfSize:14] expectedCode:@"[UIFont systemFontOfSize:14.0]"];
34 32 }
35 33
36   -- (void)testDefaultSystemFont;
37   -{
38   - id value = [NSArray arrayWithObjects:@"system", [NSNumber numberWithFloat:14], nil];
  34 +- (void)testDefaultSystemFont; {
  35 + id value = @[@"system", @14.0f];
39 36 [self testValue:value expectedFont:[UIFont systemFontOfSize:14] expectedCode:@"[UIFont systemFontOfSize:14.0]"];
40 37 }
41 38
42   -- (void)testDefaultSystemBoldFont;
43   -{
44   - id value = [NSArray arrayWithObjects:@"bold", [NSNumber numberWithFloat:14], nil];
45   - [self testValue:value expectedFont:[UIFont boldSystemFontOfSize:14] expectedCode:@"[UIFont boldSystemFontOfSize:14.0]"];
  39 +- (void)testDefaultSystemBoldFont; {
  40 + id value = @[@"bold", @14.0f];
  41 + [self testValue:value expectedFont:[UIFont boldSystemFontOfSize:14]
  42 + expectedCode:@"[UIFont boldSystemFontOfSize:14.0]"];
46 43 }
47 44
48   -- (void)testDefaultSystemItalicFont;
49   -{
50   - UIFont *font = [self.converter convertValue:[NSArray arrayWithObjects:
51   - @"italic",
52   - [NSNumber numberWithFloat:14],
53   - nil]];
  45 +- (void)testDefaultSystemItalicFont; {
  46 + UIFont *font = [self.converter convertValue:@[@"italic",
  47 + @14.0f]];
54 48
55 49 STAssertNotNil(font, nil);
56 50 STAssertEqualObjects(font, [UIFont italicSystemFontOfSize:14], nil);
57 51 }
58 52
59   -- (void)testValue:(id)value expectedFont:(UIFont *)expectedFont expectedCode:(NSString *)expectedCode;
60   -{
  53 +- (void)testValue:(id)value expectedFont:(UIFont *)expectedFont expectedCode:(NSString *)expectedCode; {
61 54 UIFont *font = [self.converter convertValue:value];
62 55 STAssertEqualObjects(font, expectedFont, nil);
63 56
@@ -65,13 +58,11 @@ - (void)testValue:(id)value expectedFont:(UIFont *)expectedFont expectedCode:(NS
65 58 STAssertEqualObjects(code, expectedCode, nil);
66 59 }
67 60
68   -- (void)setUp;
69   -{