mirror of
https://github.com/nickshanks/ResKnife.git
synced 2025-01-03 04:31:27 +00:00
Add missing files.
This commit is contained in:
parent
cc7c0f07c7
commit
f8552926f4
9
Cocoa/Categories/NSNumber-Range.h
Normal file
9
Cocoa/Categories/NSNumber-Range.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@interface NSNumber (ResKnifeRangeExtensions)
|
||||||
|
|
||||||
|
- (BOOL)isWithinRange:(NSRange)range; // location <= self <= location+length
|
||||||
|
- (BOOL)isExclusivelyWithinRange:(NSRange)range; // location < self < location+length
|
||||||
|
- (BOOL)isBoundedByRange:(NSRange)range; // location <= self < location+length
|
||||||
|
|
||||||
|
@end
|
23
Cocoa/Categories/NSNumber-Range.m
Normal file
23
Cocoa/Categories/NSNumber-Range.m
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#import "NSNumber-Range.h"
|
||||||
|
|
||||||
|
@implementation NSNumber (ResKnifeRangeExtensions)
|
||||||
|
|
||||||
|
- (BOOL)isWithinRange:(NSRange)range // location <= self <= location+length
|
||||||
|
{
|
||||||
|
// e.g. for {6,1} a value of 6.000 will return true, as will 7.000
|
||||||
|
return [self compare:[NSNumber numberWithInt:range.location]] != NSOrderedAscending && [self compare:[NSNumber numberWithInt:range.location+range.length]] != NSOrderedDescending;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isExclusivelyWithinRange:(NSRange)range // location < self < location+length
|
||||||
|
{
|
||||||
|
// e.g. for {6,1} a value of 6.000 will return false, 6.001 will return true, 6.999 will return true, 7.000 false
|
||||||
|
return [self compare:[NSNumber numberWithInt:range.location]] == NSOrderedDescending && [self compare:[NSNumber numberWithInt:range.location+range.length]] == NSOrderedAscending;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isBoundedByRange:(NSRange)range // location <= self < location+length
|
||||||
|
{
|
||||||
|
// e.g. for {6,1} a value of 6.000 will return true, 6.999 will return true, 7.000 will not
|
||||||
|
return [self compare:[NSNumber numberWithInt:range.location]] != NSOrderedAscending && [self compare:[NSNumber numberWithInt:range.location+range.length]] == NSOrderedAscending;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
8
Cocoa/Categories/NSString-FSSpec.h
Normal file
8
Cocoa/Categories/NSString-FSSpec.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@interface NSString (ResKnifeFSSpecExtensions)
|
||||||
|
|
||||||
|
- (FSRef *)createFSRef;
|
||||||
|
- (FSSpec *)createFSSpec;
|
||||||
|
|
||||||
|
@end
|
28
Cocoa/Categories/NSString-FSSpec.m
Normal file
28
Cocoa/Categories/NSString-FSSpec.m
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#import "NSString-FSSpec.h"
|
||||||
|
|
||||||
|
@implementation NSString (ResKnifeFSSpecExtensions)
|
||||||
|
|
||||||
|
- (FSRef *)createFSRef
|
||||||
|
{
|
||||||
|
FSRef *fsRef = NULL;
|
||||||
|
OSStatus error = FSPathMakeRef( [self fileSystemRepresentation], &fsRef, NULL );
|
||||||
|
if( error == noErr )
|
||||||
|
return fsRef;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (FSSpec *)createFSSpec
|
||||||
|
{
|
||||||
|
FSRef *fsRef = NULL;
|
||||||
|
FSSpec *fsSpec = NULL;
|
||||||
|
OSStatus error = FSPathMakeRef( [self fileSystemRepresentation], &fsRef, NULL );
|
||||||
|
if( error == noErr )
|
||||||
|
{
|
||||||
|
error = FSGetCatalogInfo( &fsRef, kFSCatInfoNone, NULL, NULL, fsSpec, NULL );
|
||||||
|
if( error == noErr )
|
||||||
|
return fsSpec;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
Loading…
Reference in New Issue
Block a user