2007-03-14 02:29:16 +00:00
|
|
|
//
|
|
|
|
// IndexFormatter.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Zaphod Beeblebrox on 3/13/07.
|
|
|
|
// Copyright 2007 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "IndexFormatter.h"
|
|
|
|
|
|
|
|
@implementation IndexFormatter
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSString *)stringForObjectValue:(id)object {
|
|
|
|
NSString *result = nil;
|
2007-03-14 02:29:16 +00:00
|
|
|
int value;
|
|
|
|
|
|
|
|
if(nil == object || NO == [object isKindOfClass:[NSNumber class]]) {
|
|
|
|
return nil;
|
|
|
|
}
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2007-03-14 02:29:16 +00:00
|
|
|
value = ([object intValue] + 1);
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2007-03-14 02:29:16 +00:00
|
|
|
result = [NSString stringWithFormat:@"%i", value];
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2007-10-13 07:09:46 +00:00
|
|
|
return result;
|
2007-03-14 02:29:16 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (BOOL)getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error {
|
2007-03-14 02:29:16 +00:00
|
|
|
if(NULL != object) {
|
|
|
|
*object = [NSNumber numberWithInt:[string intValue]];
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2007-03-14 02:29:16 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSAttributedString *)attributedStringForObjectValue:(id)object withDefaultAttributes:(NSDictionary *)attributes {
|
|
|
|
NSAttributedString *result = nil;
|
|
|
|
|
2007-03-14 02:29:16 +00:00
|
|
|
result = [[NSAttributedString alloc] initWithString:[self stringForObjectValue:object] attributes:attributes];
|
2016-05-05 20:05:39 +00:00
|
|
|
return result;
|
2007-03-14 02:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|