-
Notifications
You must be signed in to change notification settings - Fork 0
/
pmsNSUtility.m
90 lines (63 loc) · 2.27 KB
/
pmsNSUtility.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
// pmsNSUtility.m
// PDFGarden
//
// Created by Dave Carlton on 09/24/10.
// Copyright 2010 PolyMicro Systems. All rights reserved.
//
#import "pmsNSUtility.h"
#define QUERY_DO(query) static NSString *query = @""
#define QUERY_END @"";
/*
QUERY_DO(query)
"UPDATE settings SET "
" username = ?,"
" password = ?,"
" last_sync = ?,"
" selected_feed = ?,"
" selected_feed_type = ?,"
" selected_entry = ?,"
" selected_view = ? "
QUERY_END
*/
@interface NSObject (PMExtension)
- (NSString *)singleLineDescription;
@end
@implementation NSObject (PMExtension)
- (NSString *)singleLineDescription
{
return [[[self description] componentsSeparatedByString:@"\n"] componentsJoinedByString:@" "];
}
/*
Every class that descends from NSObject will respond to the singleLineDescription method.
For example, I sometimes find small arrays and dictionaries are easier to read when they're logged on a single line:
NSArray *testArray = [NSArray arrayWithObjects:@"aaa", @"bbb", @"ccc", nil];
NSLog(@"+++ testArray -- %@", testArray);
NSLog(@"+++ single line -- %@", [testArray singleLineDescription]);
NSDictionary *testDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
@"one", @"1",
@"two", @"2",
@"three", @"3",
nil];
NSLog(@"+++ testDictionary -- %@", testDictionary);
NSLog(@"+++ single line -- %@", [testDictionary singleLineDescription]);
*/
@end
@implementation PMSUtility
@end
BOOL BooleanToBOOL(Boolean inBoolean)
{ return (inBoolean == TRUE) ? YES : NO; }
Boolean BOOLToBoolean(BOOL inBool)
{ return(inBool == YES ); }
CFBooleanRef BooleanToCFBoolean(Boolean inBoolean)
{ return( (inBoolean == TRUE) ? kCFBooleanTrue : kCFBooleanFalse ); }
CFBooleanRef BOOLToCFBoolean(BOOL inBool)
{ return( (inBool == YES) ? kCFBooleanTrue : kCFBooleanFalse ); }
BOOL CFBooleanToBOOL(CFBooleanRef inCFBoolean)
{ return( BooleanToBOOL(CFBooleanGetValue(inCFBoolean)) ); }
Boolean CFBooleanToBoolean(CFBooleanRef inCFBoolean)
{ return( CFBooleanGetValue(inCFBoolean) ); }
CFBooleanRef NSNumberToCFBoolean(NSNumber* inNSNum)
{ return( BOOLToCFBoolean([inNSNum boolValue]) ); }
NSNumber* CFBooleanToNSNumber(CFBooleanRef inCFBoolean)
{ return [NSNumber numberWithBool:CFBooleanToBOOL(inCFBoolean)]; }