I have an NSString
category class (NSString+URLEncoding.h
).
I am running into and unknown selector crash, because the string I am calling the category method has been optimized into an NSCFConstantString
by iOS.
-[__NSCFConstantString URLEncodedString]: unrecognized selector sent to instance 0x290174
I learned of the NSCFConstantString
vs. NSCFString
optimizations in iOS 5 from:
http://www.cocoanetics.com/2012/03/beware-of-nsstring-optimizations/
Is anyone aware of how I can get the NSString category to include the Constant strings or even force the var to be an NSString/NSCFString
and not an NSCFConstantString
?
Cheers, Z
-edit-
- Linker flags
-ObjC -all_load
are both already implemented - NSString+URLEncoding.m is included in the targets compile sources
- NSString+URLEncoding.m implements the URLEncodedString method.
- Checked for zombies.
I am adding a sharing service to ShareKit 2.0
header:
@interface NSString (OAURLEncodingAdditions)
- (NSString *)URLEncodedString;
implementation:
@implementation NSString (OAURLEncodingAdditions)
- (NSString *)URLEncodedString
{
NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)self,
NULL,
CFSTR("!*'();:@&=+$,/?%#[]"),
kCFStringEncodingUTF8);
[result autorelease];
return result;
}