2008-02-17 20:46:55 +00:00
|
|
|
//
|
|
|
|
// StringToURLTransformer.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Vincent Spader on 2/17/08.
|
|
|
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "StringToURLTransformer.h"
|
|
|
|
|
|
|
|
@implementation StringToURLTransformer
|
2008-02-17 21:18:01 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
+ (Class)transformedValueClass {
|
|
|
|
return [NSURL class];
|
|
|
|
}
|
|
|
|
+ (BOOL)allowsReverseTransformation {
|
|
|
|
return YES;
|
|
|
|
}
|
2008-02-17 20:46:55 +00:00
|
|
|
|
|
|
|
// Convert from string to NSURL
|
|
|
|
- (id)transformedValue:(id)value {
|
2022-02-07 05:49:27 +00:00
|
|
|
if(value == nil) return nil;
|
2008-02-17 20:46:55 +00:00
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
return [NSURL URLWithString:value];
|
2008-02-17 20:46:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Convert from NSURL to string
|
|
|
|
- (id)reverseTransformedValue:(id)value {
|
2022-02-07 05:49:27 +00:00
|
|
|
if(value == nil) return nil;
|
|
|
|
|
|
|
|
return [value absoluteString];
|
2008-02-17 20:46:55 +00:00
|
|
|
}
|
|
|
|
@end
|