Skip to content

Instantly share code, notes, and snippets.

@mikeabdullah
Created January 17, 2011 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeabdullah/782896 to your computer and use it in GitHub Desktop.
Save mikeabdullah/782896 to your computer and use it in GitHub Desktop.
Simple value transfer like `NSIsNotNil`, but for NSNotFound
//
// KSIsNotNSNotFound.h
// Sandvox
//
// Created by Mike on 16/01/2011.
// Copyright 2011 Karelia Software. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface KSIsNotNSNotFound : NSValueTransformer
@end
//
// KSIsNotNSNotFound.m
// Sandvox
//
// Created by Mike on 16/01/2011.
// Copyright 2011 Karelia Software. All rights reserved.
//
#import "KSIsNotNSNotFound.h"
@implementation KSIsNotNSNotFound
+ (Class)transformedValueClass; { return [NSNumber class]; }
+ (BOOL)allowsReverseTransformation; { return NO; }
- (id)transformedValue:(id)value;
{
BOOL result = [value unsignedIntegerValue] != NSNotFound;
return NSBOOL(result);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment