Skip to content

Commit ec3bc44

Browse files
committed
Improved use of availability macros
Surprisingly, to work around the problem that older SDKs don't know the MAC_OS_X_VERSION… constants for *future* Mac OS X versions; i.e. that they are not "forward compatible", I recently read that Apple recommends hard coding the constants, i.e. 1060 for 10.6, etc. So I do it that way now. I must admit that it does make things much simpler!
1 parent 4182183 commit ec3bc44

19 files changed

+94
-29
lines changed

MAKVONotificationCenter.m

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99

1010
#import <libkern/OSAtomic.h>
1111
#import <objc/message.h>
12-
/*
13-
If you are developing with the 10.5 SDK, MAC_OS_X_VERSION_MAX_ALLOWED = 1050, MAC_OS_X_VERSION_10_5 = 1050 and the following #if will be true.
14-
If you are developing with the 10.6 SDK, MAC_OS_X_VERSION_MAX_ALLOWED = 1060, MAC_OS_X_VERSION_10_5 = 1050 and the following #if will be false.
15-
*/
16-
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5)
12+
13+
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
1714
// For some reason, this was not needed when I was using the 10.5 SDK
1815
#import <objc/objc-auto.h>
1916
#endif

SSYAboutPanelController.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern NSString* const SSYAboutPanelHelpAnchorAcknowledgements ;
55
@class ScrollingTextView;
66

77
@interface SSYAboutPanelController : NSObject
8-
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5)
8+
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
99
<NSWindowDelegate>
1010
#endif
1111
{

SSYAlert.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ + (NSInteger)tryRecoveryAttempterForError:(NSError*)error
572572
result = ok ? SSYAlertRecoverySucceeded : SSYAlertRecoveryFailed ;
573573
}
574574
else {
575-
NSLog(@"Internal Error 342-5587. Given Recovery Attempter %@ does not respond to either attemptRecoveryFromError:... method", recoveryAttempter) ;
575+
NSLog(@"Internal Error 342-5587. Given Recovery Attempter %@ does not respond to any attemptRecoveryFromError:... method", recoveryAttempter) ;
576576
}
577577
}
578578
else if (docOpeningError) {

SSYDocFileObserver.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ - (void)dealloc {
141141
- (void)pathChangedNote:(NSNotification*)note {
142142
// No need to look at flags since we registered for only SSYPathObserverChangeFlagsRename.
143143

144-
#if 1
144+
#if 0
145145
#warning Debugging SSYDocFileObserver
146146
NSLog(@"Received notification of filesystem change:\n"
147147
" Path: %@\n"

SSYDynamicMenu.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
variables for the current represented objects and selected represented object.
5252
*/
5353
@interface SSYDynamicMenu : NSMenu
54-
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5)
54+
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
5555
<NSMenuDelegate>
5656
#endif
5757
{

SSYHintableWindow.m

+68
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,73 @@ - (void)sendEvent:(NSEvent *)event {
88
[super sendEvent:event] ;
99
}
1010

11+
#if 0
12+
#warning Experimenting : Windowless
13+
14+
- (void)displayIfNeeded {
15+
if (WINDOWLESS) {
16+
return ;
17+
}
18+
[super displayIfNeeded] ;
19+
}
20+
21+
22+
- (void)display {
23+
if (WINDOWLESS) {
24+
return ;
25+
}
26+
[super display] ;
27+
}
28+
29+
- (void)orderFrontRegardless {
30+
if (WINDOWLESS) {
31+
return ;
32+
}
33+
[super orderFrontRegardless] ;
34+
}
35+
36+
- (void)orderFront:(id)sender {
37+
if (WINDOWLESS) {
38+
return ;
39+
}
40+
[super display] ;
41+
}
42+
43+
- (void)orderBack:(id)sender {
44+
if (WINDOWLESS) {
45+
return ;
46+
}
47+
[super orderFront:sender] ;
48+
}
49+
50+
- (void)makeMainWindow {
51+
if (WINDOWLESS) {
52+
return ;
53+
}
54+
[super makeMainWindow] ;
55+
}
56+
57+
- (void)makeKeyWindow {
58+
if (WINDOWLESS) {
59+
return ;
60+
}
61+
[super makeKeyWindow] ;
62+
}
63+
64+
- (void)makeKeyAndOrderFront:(id)sender {
65+
if (WINDOWLESS) {
66+
return ;
67+
}
68+
[super makeKeyAndOrderFront:sender] ;
69+
}
70+
71+
- (void)orderWindow:(NSWindowOrderingMode)orderingMode relativeTo:(NSInteger)otherWindowNumber {
72+
if (WINDOWLESS) {
73+
return ;
74+
}
75+
[super orderWindow:orderingMode relativeTo:otherWindowNumber] ;
76+
}
77+
78+
#endif
1179

1280
@end

SSYLabelledList.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@details May be used, for example for a user to select several items from a list.
1111
*/
1212
@interface SSYLabelledList : NSView
13-
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5)
13+
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
1414
<NSTableViewDataSource, NSTableViewDelegate>
1515
#endif
1616
{

SSYLabelledTextField.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<i>Favorite Animal</i>, etc. etc. Any single line of text.
99
*/
1010
@interface SSYLabelledTextField : NSControl
11-
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5)
11+
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
1212
<NSTextFieldDelegate>
1313
#endif
1414
{

SSYLaunchdGuy.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ + (NSString*)homeLaunchAgentsPath {
2121

2222

2323
+ (NSSet*)installedLaunchdAgentLabelsWithPrefix:(NSString*)prefix {
24-
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5)
24+
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060)
2525
NSArray* allAgentNames = [[NSFileManager defaultManager] directoryContentsAtPath:[self homeLaunchAgentsPath]] ;
2626
#else
2727
NSError* error = nil ;
@@ -190,7 +190,7 @@ + (BOOL)removeAgentsWithPrefix:(NSString*)prefix
190190
BOOL ok = YES ;
191191
NSString* myAgentDirectory = [self homeLaunchAgentsPath] ;
192192

193-
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5)
193+
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060)
194194
NSArray* existingFilenames = [[NSFileManager defaultManager] directoryContentsAtPath:myAgentDirectory] ;
195195
#else
196196
NSError* error = nil ;
@@ -281,7 +281,7 @@ + (BOOL)addAgentInfo:(NSDictionary*)dic
281281
NSDictionary* attributes = [NSDictionary dictionaryWithObject:octal644
282282
forKey:NSFilePosixPermissions] ;
283283
NSError* error = nil ;
284-
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5)
284+
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060)
285285
ok =[[NSFileManager defaultManager] changeFileAttributes:attributes
286286
atPath:path] ;
287287
#else

SSYMOCManager.m

+2-6
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,7 @@ - (void)attemptRecoveryFromError:(NSError*)error
134134
// that the destination not already exist, so we must "remove" it first.
135135
NSFileManager* fm = [NSFileManager defaultManager] ;
136136

137-
/*
138-
If you are developing with the 10.5 SDK, MAC_OS_X_VERSION_MAX_ALLOWED = 1050, MAC_OS_X_VERSION_10_5 = 1050 and the following #if will be true.
139-
If you are developing with the 10.6 SDK, MAC_OS_X_VERSION_MAX_ALLOWED = 1060, MAC_OS_X_VERSION_10_5 = 1050 and the following #if will be false.
140-
*/
141-
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5)
137+
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060)
142138
[fm removeFileAtPath:newPath
143139
handler:nil] ;
144140
BOOL ok = [fm movePath:oldPath
@@ -207,7 +203,7 @@ + (NSPersistentStoreCoordinator*)persistentStoreCoordinatorType:(NSString*)store
207203
NSError* error = nil ;
208204
if (ok && ((fileExists && !isDirectory) || !fileExists)) {
209205
// Create parent directory
210-
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5)
206+
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060)
211207
ok = [fm createDirectoryAtPath:parentPath
212208
attributes:nil] ;
213209
#else

SSYNetServiceResolver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum SSYNetServiceResolverState_enum {
1414
typedef enum SSYNetServiceResolverState_enum SSYNetServiceResolverState ;
1515

1616
@interface SSYNetServiceResolver : NSObject
17-
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5)
17+
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
1818
<NSNetServiceDelegate>
1919
#endif
2020
{

SSYNetServicesSearcher.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ enum SSYNetServicesSearcherState_enum {
1616
typedef enum SSYNetServicesSearcherState_enum SSYNetServicesSearcherState ;
1717

1818
@interface SSYNetServicesSearcher : NSObject
19-
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5)
19+
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
2020
<NSNetServiceBrowserDelegate>
2121
#endif
2222
{

SSYOtherApper.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#import "NSString+SSYExtraUtils.h"
55
#import "NSFileManager+SomeMore.h"
66

7-
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5) \
8-
|| (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
7+
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060)
8+
99
/*!
1010
@brief Declares stuff which is defined in the 10.6 SDK,
1111
to eliminate compiler warnings.
@@ -24,6 +24,7 @@ + (id)propertyListWithData:(NSData*)data
2424
error:(NSError**)error ;
2525

2626
@end
27+
2728
#endif
2829

2930
NSString* const SSYOtherApperErrorDomain = @"SSYOtherApperErrorDomain" ;

SSYPathObserver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
// See class documentation
11-
#define KQUEUES_WATCHER_THREAD_NEEDS_KILL_TO_EXIT (MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5)
11+
#define KQUEUES_WATCHER_THREAD_NEEDS_KILL_TO_EXIT (MAC_OS_X_VERSION_MAX_ALLOWED < 1060)
1212

1313

1414
/*!

SSYPersistentDocumentMultiMigrator.m

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#import "SSYSuperFileManager.h"
55
#import "NSError+SSYAdds.h"
66
#import "NSString+MorePaths.h"
7+
#import "NSDocument+SyncModDate.h"
78

89
NSString* const SSYPersistentDocumentMultiMigratorErrorDomain = @"SSYPersistentDocumentMultiMigratorErrorDomain" ;
910
NSString* const SSYPersistentDocumentMultiMigratorDidBeginMigrationNotification = @"SSYPersistentDocumentMultiMigratorDidBeginMigrationNotification" ;

SSYPrefsWindowController.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@interface SSYPrefsWindowController : NSWindowController
2-
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5)
2+
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
33
<NSToolbarDelegate>
44
#endif
55
{

SSYPrefsWindowController.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,13 @@ -(NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifier: (NSStrin
226226
automagically select the appropriate item when it is clicked.
227227
-------------------------------------------------------------------------- */
228228

229-
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
229+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
230+
230231
-(NSArray*) toolbarSelectableItemIdentifiers: (NSToolbar*)toolbar
231232
{
232233
return [itemsList allKeys];
233234
}
235+
234236
#endif
235237

236238

SSYSqliter.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ - (NSArray*)allPrimaryKeysInTable:(NSString*)table
768768
- (BOOL)checkpointAndCloseError_p:(NSError**)error_p {
769769
if (!m_db) {
770770
return YES ;
771-
// because sqlite3_wal_checkpoint(NULL, NULL) will crash
771+
// because sqlite3_wal_checkpoint(NULL, NULL) will crash
772772
}
773773

774774
int result ;

SSYSuperFileManager.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ - (BOOL)fileExistsAtPath:(NSString*)path
235235
- (BOOL)canExecutePath:(NSString *)fullPath
236236
groupID:(uid_t)groupID
237237
userID:(uid_t)userID {
238-
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5)
238+
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060)
239239
NSDictionary* attributes = [self fileAttributesAtPath:fullPath
240240
traverseLink:YES] ;
241241
#else

0 commit comments

Comments
 (0)